我正在用這一個頭撞牆。我在我的htaccess文件中有一個重寫規則,它適用於所有的url,但只有一個。這裏的線RewriteRule不適用於某個特定情況
RewriteRule ^([a-zA-Z0-9_-]+)$ content.php?linkid=$1 [L]
以及完整的htacess
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
#RewriteRule ^contact-us content.php?linkid=contact-us [L,R]
RewriteRule ^([a-zA-Z0-9_-]+)$ content.php?linkid=$1 [L]
RewriteRule ^news/([a-zA-Z0-9_-]+)/([0-9]+)$ media.php?news=$1&pgNo=$2 [L]
RewriteRule ^news-details/([a-zA-Z0-9_-]+)$ media-detail.php?news_short=$1 [L]
RewriteRule ^services-list/([a-zA-Z0-9_-]+)$ services-list-new.php?services_list=$1 [L]
RewriteRule ^specialities/([a-zA-Z0-9_-]+)/([0-9]+)$ speciality-listing.php?speciality=$1&pgNo=$2 [L]
RewriteRule ^services-details/([a-zA-Z0-9_-]+)$ services.php?speciality_short=$1 [L]
RewriteRule ^treatment-detail/([a-zA-Z0-9_-]+)$ treatment-detail.php?treatment_short=$1 [L]
RewriteRule ^testimonial/([a-zA-Z0-9_-]+)/([0-9]+)$ testimonials.php?testimonial=$1&pgNo=$2 [L]
RewriteRule ^testimonial-detail/([a-zA-Z0-9_-]+)$ testimonial-detail.php?test_short=$1 [L]
RewriteRule ^photo-gallery-detail/([a-zA-Z0-9_-]+)$ photo-gallery-detail.php?photo_short=$1 [L]
RewriteRule ^media/([a-zA-Z0-9_-]+)/([0-9]+)$ media.php?media=$1&pgNo=$2 [L]
RewriteRule ^media-detail/([a-zA-Z0-9_-]+)$ media-detail.php?media_detail=$1 [L]
RewriteRule ^doctor-profile/([a-zA-Z0-9_-]+)$ doctor.php?doc_short=$1 [L]
RewriteRule ^make-an-appointment/([a-zA-Z0-9_-]+)$ make-an-appointmen.php?appointment_id=$1 [L]
RewriteRule ^current-openings/([a-zA-Z0-9_-]+)/([0-9]+)$ current-openings.php?current_opening=$1&pgNo=$2 [L]
</IfModule>
所以這個工程的domain.com/privacy-policy
都到domain.com/content.php?linkid=privacy-policy
和其他幾個人喜歡推薦,服務,事業等
,但它不」 t工作聯繫我們,即domain.com/contact-us
我甚至嘗試過硬編碼版本是上面的評論線。任何想法傢伙?
編輯: 我使用url domain.com/content.php?linkid=contact-us
其工作正常,但domain.com/contact-us
給我的錯誤所請求的網址/接觸我們並沒有在此服務器上發現了嘗試。。
我也發現了另一個不起作用的網址,它是domain.com/media/list/1
其中說在此服務器上找不到請求的網址/media.html/list/1。我不知道它從哪裏得到media.html。文件結構中有一個名爲media.html的文件,所以我刪除了該文件,並且鏈接開始工作。儘管如此,聯繫我們並非如此。
這不是一個真正的目錄。該網站通過將其重定向到content.php以加載唯一的'linkid'值來加載所有頁面。我不認爲我在Apache配置中有任何東西,但我無法從cPanel知道,對吧?我也進入了加載頁面的url'domain.com/linkid = contact-us'。這只是重寫不起作用 – VeeK
這很奇怪,但看着你的代碼這些規則不是'/ contact-us'不工作的原因。你爲'/ contact-us'獲得404嗎? – anubhava
嘗試將「選項」行更改爲「選項+ FollowSymlinks -MultiViews」 – anubhava