0

i have 2 .htaccess files

first in /public_html/

#ErrorDocument 404 https://example.com/en/404.php
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/ws/
RewriteCond %{REQUEST_URI} !/en/
RewriteCond %{REQUEST_URI} !/ar/
RewriteCond %{QUERY_STRING} !lang=en
RewriteCond %{QUERY_STRING} !lang=ar
RewriteRule (.*) $1?lang=en [QSA]

and the other file is in /public_html/jobs/

RewriteOptions inherit
DirectoryIndex index.php
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} ((\d+)?)
RewriteRule ((\d+).*?)  /job/index.php?JobID=$2 [QSA]

i want to redirect URL from:

https://example.com/jobs/123

to:

https://example.com/job/index.php?JobID=123&lang=en

but the result is

https://example.com/job/?JobID=1196147

without the lang parameter

i don't know why it isn't working and i need the rules in 2 files because there's many other rules in the root file

Thanks.

Amr Ahmed
  • 13
  • 2
  • Given the directives you've posted, this should already perform the desired rewrite (not a "redirect") with the `lang` parameter, although arguably more "complex" than they need to be. (The stated "result" is also missing the `index.php` filename - which doesn't seem possible given the directives you posted - unless that is a typo in your question?) However, the HTTP to HTTPS redirect in the parent `.htaccess` file would cause problems, because with the `inherit` option, the parent directives are inherited _after_ the child directives. – MrWhite Jul 26 '19 at 22:39
  • "there's many other rules in the root file" - my guess would be that there is a conflict with these "other rules". Please post your entire `.htaccess` file(s). – MrWhite Jul 26 '19 at 22:41

1 Answers1

1

I just had the same issue - I resolved it by using RewriteOptions InheritBefore instead of just RewriteOptions Inherit so the .htaccess file in the parent directory was processed before the one in the sub-directory

b4tch
  • 111
  • 1