簡體   English   中英

使用.htaccess的URL 127.0.0.1從URL中刪除index.php

[英]Remove index.php from url using .htaccess for urls 127.0.0.1

我有這樣的網址

http://127.0.0.1:420/github/myproject/users

和我的.htacess文件具有以下代碼

<IfModule mod_rewrite.c>
DirectoryIndex index.php
RewriteEngine on
RewriteBase /github/myproject
RewriteCond $1 !^(index\.php|images|style|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] 
</IfModule>

有人可以幫助我如何編寫適合我的url的RewriteRule表達式嗎? 謝謝你的幫助

只需在頂部添加以下行:

RewriteRule ^/github/myproject/(.*)$ /github/myproject/index.php/$1 [NC]

因此它將變為:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^/github/myproject/(.*)$ /github/myproject/index.php/$1 [NC]
    DirectoryIndex index.php
    RewriteBase /github/myproject
    RewriteCond $1 !^(index\.php|images|style|js|robots\.txt|favicon\.ico)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] 
</IfModule>

請告訴我它是否適合您!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM