2

This is the original URL

http://localhost/naranjeshaltd/index.php?url=home

and I want redirect it to

http://localhost/naranjeshaltd/home

I have tried this htaccess code but it is redirecting page to http://localhost/xampp

Options +FollowSymLinks
RewriteEngine on

RewriteBase /naranjeshaltd
RewriteRule ^(.*)$ /index.php?url=$1 [L]

But when I use this htaccess code everything working fine

Options +FollowSymLinks
RewriteEngine on

RewriteBase /naranjeshaltd
RewriteRule home$ index.php?url=home 

but its a static method, how can I do this for all pages?

4

2 回答 2

2

我可以在这里看到两个主要问题:

  1. 您应该避免重定向到index.php真正的文件/目录/链接。
  2. 不要/用作目标 URL 中的起始斜杠,否则它不会与您的 RewriteBase 相关

将您的代码更改为:

RewriteBase /naranjeshaltd/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
于 2013-04-26T19:05:33.057 回答
0

你试过这个吗?

Options +FollowSymLinks
RewriteEngine on

RewriteBase /naranjeshaltd
RewriteRule ^(.*)$ /naranjeshaltd/index.php?url=$1 [L]
于 2013-04-26T18:59:46.180 回答