2016-11-01 25 views
1

私はこれを見ました:htaccess remove index.php from urlしかしそれはうまくいかなかったし、コメントの中でトップの答えに不一致があるようです。Htaccess URLからIndex.phpを削除してください

私がhttp://www.example.com/thanksgiving/index.php/getThankyouと入力すると、欲しいページが表示されます。

私はhttp://www.example.com/thanksgiving/getThankyouに入力した場合、私が得る私は私のhtaccessで試してみた何404

:どのように私はそれを行うのですか

<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/またはURLに/thanksgivingで始まる任意のURL適切なリソースが提供されますか?再度、現在index.phpがURLにあるときに利用可能です。

は、私も試してみました:RewriteRule ^/thanksgiving/[^/]*/$ /thanksgiving/index.php/$1 [L]が、それは...どちらか

編集]を動作しませんでした:それは、htaccessファイルの一部を見えたワードプレスによって設定されており、上記の目的の動作と競合することができる。

同じ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/のURLとどのように調和させるのですか?

編集:

上記はrootだけに関係

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] 
+0

他の回答へのリンクは正しいです。なぜあなたが持っている方法で 'RewriteRule'を変更したのか分かりません。それを 'RewriteRule ^(。*)$ /index.php?/$1 [L]'に戻してください。また、 'IfModule'の間にある必要はありません。 'RewriteEngine On'を使って作業するだけです。 – Lag

+0

@thickguru書き直したいURLは'/thanksgiving/'で始まるURLなので、変更しました –

答えて

1

://感謝祭/

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(?:thanksgiving/)?(.*)$ /thanksgiving/index.php/$1 [L] 
</IfModule> 

をそれ以外のルールはダブルledingスラッシュ(つまりで始まるURIを受け入れます)。

+0

2番目のスラッシュを改行する必要がありますか? –

+0

編集内容をご覧ください... –

+0

@SummerDeveloperあなたのwpや他のrewriteRulesの前にこれを追加してください。 – starkeen

関連する問題