[英]Rewrite codeigniter URL with htaccess
我需要通過Codeigniter中的Apache mod-rewrite
URL
頁面名稱為example.com/pages/page1
,我需要通過example.com/welcome.html
重命名。
我在htaccess
文件中寫了這個規則
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^pages/page1$ welcome.html [PT,L]
沒用 我怎樣才能做到這一點?。
嘗試這個:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^sys.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^app.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
假設index.php是您的索引頁面。
並更改config.php
$config['index_page'] = '';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.