我有一个带有参数的 URL,我希望将其转换为 sef URL:
想:
http://map.tautktiv.com/street.php?address=abc
成为:
http://map.tautktiv.com/street/address/abc
或者
http://map.tautktiv.com/address/abc
尝试了几种在线工具来生成.htaccess
规则,但它们都对 URL 没有任何影响,.htaccess
文件处于活动状态(试图在其中放入一些乱码并得到错误 500)
这些是我尝试过的规则:
1.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^address-([^-]*)$ /street.php?address=$1 [L]
RewriteRule street/address/(.*) street.php?address=$1
2.
Options +FollowSymLinks
RewriteEngine on
RewriteRule /address/(.*)\.php street.php?address=$1
3.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# add whatever other special conditions you need here
RewriteRule ^/([0-9]+)-(.*)$ /street.php?address=$1 [L]
RewriteRule /(.*)/(.*)/$ street.php?address=$1
该站点是一个子域,其中文件驻留在共享托管 GoDaddy 服务器的子目录中,还尝试将这些规则应用于其.htaccess
上方目录中的目录,结果相同。
根据以下建议也尝试过
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^street/address/(.*)$ street.php?address=$1 [r=301,L]
RewriteRule ^address/(.*)$ street.php?address=$1 [r=301,L]
RewriteRule ^street/address/(.*)$ street.php?address=$1 [r=301,L]
同样的结果,什么也没有发生。
试图直接从主域转到页面,但结果相同:
http://tautktiv.com/map/streets/street.php?address=abc