2016-11-01 3 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과 어떻게 조화시켜야합니까?

편집 :

위는 루트에 관련된

(public_html) htaccess로는, 아래 /thanksgiving/ 자체에 htaccess로는, 충돌을 분석하십시오, 모든 도움을 주셔서 감사합니다! 그렇지 않으면 규칙이 이중 leding 슬래시로 시작하는 URI를 받아

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

(예 :

<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 /'로 시작하기 때문에 변경했습니다 –

답변

1

당신은 당신의 재 작성 패턴에서 슬래시를 제거해야 // 감사/).

+0

두 번째 슬래시도 제거해야합니까? –

+0

수정 사항을 참조하십시오 ... –

+0

@SummerDeveloper wp 또는 기타 rewriteRules 앞에 추가하십시오. – starkeen

관련 문제