我期待使用URL重寫訪問此...從漂亮到醜陋重寫URL? /東西 - > A =財產以後
通過......
因此,通過使用? url.com/value我實際上正在加載url.com/?a=value。
我假設我需要在htaccess文件中進行重寫,然後以某種方式在index.php中檢測到這一點並將字段值拉出來?不幸的是,這有點超出我的想法,所以非常感謝你的幫助。
謝謝!
我期待使用URL重寫訪問此...從漂亮到醜陋重寫URL? /東西 - > A =財產以後
通過......
因此,通過使用? url.com/value我實際上正在加載url.com/?a=value。
我假設我需要在htaccess文件中進行重寫,然後以某種方式在index.php中檢測到這一點並將字段值拉出來?不幸的是,這有點超出我的想法,所以非常感謝你的幫助。
謝謝!
這是像你需要一個「漂亮」的URL的標準htaccess文件:
#.htaccess file
Options +FollowSymLinks
RewriteEngine On
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?a=$1 [L]
然後在您的index.php,你可以從「一」變量獲得最初請求的路徑。
$path = $_GET['a'];
這的.htaccess代碼考慮到像http://url.com/value?parameter=something
RewriteEngine On
RewriteRule ^([A-Za-z0-9-/]+)\&(.*)$ /$1?$2 [R]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-/_]+)$ /index.php?a=$1&${QUERY_STRING} [L,QSA]
當然這之前... – 2011-11-11 23:12:14
http://stackoverflow.com/questions/6319805/setting-up-a被問-bunch-的短型重定向的URL – 2011-11-11 23:16:07