我想重定向: https://www.example.com/whatever-part-is-coming-after-the-url 到 https://www.example.com/index.php?url=whatever-part-is-coming-after-the-urlHT訪問重定向到單個文件
不改變地址欄的要求。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
如果我用這個,它爲URL的喜歡https://example.com/foo,但不是https://example.com/foo/bar(所有相對URL,如內容/ styles.css的是現在富/內容/ styles.css中,這讓404錯誤)。
當我添加
[R=301]
重定向是做正確的,但它顯示了一個「醜陋」的網址。 有沒有辦法兼得?
我很抱歉浪費你的時間。我想我會使用http://stackoverflow.com/questions/3899991/htaccess-rewrite-breaks-relative-paths中的方法 – sprunk