我看着這個:htaccess remove index.php from url但它沒有工作,並在評論中似乎有分歧的頂部答案。Htaccess從URL中刪除Index.php
如果我輸入http://www.example.com/thanksgiving/index.php/getThankyou,我就會得到我要送達的頁面。
如果我在http://www.example.com/thanksgiving/getThankyou型我得到一個404
我在我的htaccess已經試過:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/thanksgiving/(.*)/$ /thanksgiving/index.php/$1 [L]
</IfModule>
我怎麼做,所以/thanksgiving/getThankyou/
或開頭的網址/thanksgiving
任何網址導致適當的資源被服務?同樣,當index.php
位於url中時,它當前可用。
我也試過:RewriteRule ^/thanksgiving/[^/]*/$ /thanksgiving/index.php/$1 [L]
但沒有工作,要麼...
編輯:這似乎htaccess的一部分是由WordPress的設置,並且可以與上面所期望的行爲相沖突:
同樣的htaccess的wordpress部分是:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
這是干擾?我如何與不屬於Wordpress應用程序的/thanksgiving/
網址協調?
編輯:
以上僅適用於根(public_html
)htaccess的,下面是/thanksgiving/
本身htaccess的,請分析矛盾,感謝您的幫助!
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase/
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# Do not change this line.
# Change example.com to your domain name
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change your_app_name to the subfolder name
RewriteCond %{REQUEST_URI} !^/thanksgiving/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change your_app_name to the subfolder name
# Change example.com to your domain name
RewriteRule ^(.*)$ /thanksgiving/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ thanksgiving/index.php [L]
指向其他答案的鏈接是正確的。我不確定你爲什麼按照你的方式改變了'RewriteRule'。把它改回'RewriteRule ^(。*)$ /index.php?/$1 [L]'。它也不需要在'IfModule'之間。應該使用'RewriteEngine On'工作' – Lag
@thickguru我改變了它,因爲我想重寫的唯一URL是那些以'/ thanksgiving /'開頭的' –