http://abc.com/test/batch/profile/anynamehtaccess的重定向文件與沒有文件擴展名並將參數傳遞給一個文件
在上述URL anyname取決於所選擇的鏈接而變化。
我重定向上述網址可friend.php,我應該通過anyname作爲參數傳遞給該文件
我怎樣才能做到這一點?
http://abc.com/test/batch/profile/anynamehtaccess的重定向文件與沒有文件擴展名並將參數傳遞給一個文件
在上述URL anyname取決於所選擇的鏈接而變化。
我重定向上述網址可friend.php,我應該通過anyname作爲參數傳遞給該文件
我怎樣才能做到這一點?
把這個在您的.htaccess
:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^profile/([a-z0-9]+)$ friend.php?username=$1 [NC,L]
這讓人們訪問你的網站的以下網址:
http://www.yoursite.com/profile/abc
http://www.yoursite.com/profile/abc123
http://www.yoursite.com/profile/123
但是,除字母數字以外的任何其他字符都不符合上述重寫要求。
Edit:
如果你真的將保持http://www.yoursite.com/test/batch/
-url中,.htaccess
就必須進行相應的調整。我只是假設你會使用http://www.yoursite.com/
的根。
它的工作原理。感謝您的解決方案。 – nithi
你需要做這樣的事情:
RewriteRule ^/test/batch/profile/([^/?]*)$ friend.php?param=$1
究竟會在哪裏'friend.php'是什麼?我假設'http:// abc.com/friend.php'? – Alex
friend.php位於批處理文件夾中。配置文件是附加的字符串不是文件夾 – nithi