一盞燈的服務器,我想要的網址在LAMP服務器上,我希望將URL http://example.com/index.php重寫爲http://example.com。我怎麼做?
http://example.com/index.php重寫簡單地
http://example.com
我現在的.htaccess文件如下...
IndexIgnore *
ErrorDocument 400 /index.php?module=error&action=error
ErrorDocument 401 /index.php?module=error&action=error
ErrorDocument 403 /index.php?module=error&action=error
ErrorDocument 404 /index.php?module=error&action=error
ErrorDocument 500 /index.php?module=error&action=error
RedirectMatch 301 ^/media/$/
RedirectMatch 301 ^/media/documents/$/
RedirectMatch 301 ^/media/graphics/$/
RedirectMatch 301 ^/media/photos/$/
RedirectMatch 301 ^/library/$/
RedirectMatch 301 ^/library/css/$/
RedirectMatch 301 ^/library/ht/$/
RedirectMatch 301 ^/library/js/$/
RedirectMatch 301 ^/library/php/$/
RewriteEngine on
RewriteBase/
RewriteRule ^home$ /index.php?module=home&action=frontpage
RewriteRule ^home/$ /index.php?module=home&action=frontpage
RewriteRule ^home/([^/\.]+)$ /index.php?module=home&action=$1
RewriteRule ^home/([^/\.]+)/$ /index.php?module=home&action=$1
RewriteRule ^cv$ /index.php?module=home&action=cv
RewriteRule ^cv/$ /index.php?module=home&action=cv
RewriteRule ^release$ /index.php?module=release&action=release
RewriteRule ^release/$ /index.php?module=release&action=release
RewriteRule ^photos$ /index.php?module=gallery&action=album&album=general
RewriteRule ^photos/$ /index.php?module=gallery&action=album&album=general
RewriteRule ^gallery$ /index.php?module=gallery&action=album&album=general
RewriteRule ^gallery/$ /index.php?module=gallery&action=album&album=general
RewriteRule ^gallery/([^/\.]+)$ /index.php?module=gallery&action=album&album=$1
RewriteRule ^gallery/([^/\.]+)/$ /index.php?module=gallery&action=album&album=$1
RewriteRule ^gallery/([^/\.]+)/([^/\.]+)$ /index.php?module=gallery&action=album&album=$1$&page=$2
RewriteRule ^gallery/([^/\.]+)/([^/\.]+)/$ /index.php?module=gallery&action=album&album=$1$&page=$2
RewriteRule ^gallery/([^/\.]+)/([^/\.]+)/([^/\.]+)$ /index.php?module=gallery&action=item&album=$1$&page=$2&item=$3
RewriteRule ^gallery/([^/\.]+)/([^/\.]+)/([^/\.]+)/$ /index.php?module=gallery&action=item&album=$1$&page=$2&page=$3
RewriteRule ^handouts$ /index.php?module=home&action=handouts
RewriteRule ^handouts/$ /index.php?module=home&action=handouts
RewriteRule ^links$ /index.php?module=home&action=links
RewriteRule ^links/$ /index.php?module=home&action=links
RewriteRule ^contact$ /index.php?module=home&action=contact
RewriteRule ^contact/$ /index.php?module=home&action=contact
RewriteRule ^login$ /index.php?module=authentication&action=login
RewriteRule ^login/$ /index.php?module=authentication&action=login
RewriteRule ^logout$ /index.php?module=authentication&action=logout
RewriteRule ^logout/$ /index.php?module=authentication&action=logout
RewriteRule ^copyright$ /index.php?module=home&action=copyright
RewriteRule ^copyright/$ /index.php?module=home&action=copyright
RewriteRule ^error$ /index.php?module=error&action=error
RewriteRule ^error/$ /index.php?module=error&action=error
我應該如何修改我的.htaccess文件來實現這個基本重寫?此外,任何其他反饋與我的.htaccess代碼將不勝感激。
在此先感謝!
我從來沒有見過這樣一個濃密的.htaccess文件在我的生活中。你真的寫了所有的亂七八糟,不知道如何添加這個簡單的重寫規則? – 2010-09-22 13:59:15
我寫過,哈哈,但是我遇到了重定向循環錯誤的問題。也許它太濃密了!大聲笑任何關於如何使代碼更有效的建議? – Drew2345 2010-09-22 14:33:39