在apache的.htaccess文件,我已經寫,國防部重寫問題
重寫規則^ $動物的index.php?類型=動物
它重定向到http://localhost/animalshttp://localhost/index.php?type=animals
當url輸入爲http://localhost/animals/則發生錯誤,找不到 文件。
什麼是正確的語法重定向到http://localhost/index.php?type=animals
在apache的.htaccess文件,我已經寫,國防部重寫問題
重寫規則^ $動物的index.php?類型=動物
它重定向到http://localhost/animalshttp://localhost/index.php?type=animals
當url輸入爲http://localhost/animals/則發生錯誤,找不到 文件。
什麼是正確的語法重定向到http://localhost/index.php?type=animals
是與setthing這一規則做,如果指定了基礎,那麼所有鏈接的基本路徑
RewriteBase/
做既http://localhost/animals和http://localhost/animals/這應該工作:
RewriteRule ^animals/?$ index.php?type=animals
嘗試RewriteRule ^animals/?$ index.php?type=animals
您應該使用L
標誌標記結束的規則和QSA
來保存新的查詢參數,如下所示:
RewriteRule ^animals/?$ index.php?type=animals [L,QSA,NC]
NC不用於比較。
是路徑是否正確? – Simone
該頁面同時在'http:// localhost/animals /'和'http:// localhost/animals'中打開,但當我使用'http:// localhost/animals /'時,css,js文件不會加載。但是使用'http:// localhost/animals'完全適用。 –
@BhaveshGangani你應該編碼你的html,所有對css和js文件的引用(以及其他html頁面的鏈接)對你的項目路徑是絕對的。因此,如果您的網站位於http://www.example.com/,則所有到文件的鏈接都必須是'/ css/style.css'而不是'css/style.css'。如果您的網頁位於http://www.example.com/yoursite/,則所有鏈接都必須如'/ yoursite/css/style.css' –