开发者

mod_rewrite redirection issue

开发者 https://www.devze.com 2023-03-06 00:47 出处:网络
I\'ve looked through the related questions, but no luck. I\'m trying to rewrite something like this: http://www.example.com/v2/index.php/en/company/careers/training-and-implementation-specialist/

I've looked through the related questions, but no luck.

I'm trying to rewrite something like this: http://www.example.com/v2/index.php/en/company/careers/training-and-implementation-specialist/

to this: http://www.example.com/en/company/careers/training-and-implementation-special开发者_JS百科ist/

To make things a little more confusing, The "index.php" in the URL above is a file, not a directory. I'm trying to make a rule where www.example.com/v2/index.php/(anything) turns into www.example.com/(anything)

I feel like this should be easy, and I tried this: RewriteRule ^v2/index.php/(.*) /$1 [L]

but no luck -- it gets 404'd for anything I try that's in /v2/index.php.

Any suggestions?


If I'm understanding what you want to do, I believe you have it backwards. Try this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ v2/index.php/$1 [L]


The problem is with . between index and php in RewriteRule ^v2/index.php/(.*) /$1 [L]

To rewrite try-RewriteRule ^v2/index\.php/(.*)$ /$1 [L]

if you want to redirect, change [L] to [R,L]

0

精彩评论

暂无评论...
验证码 换一张
取 消