【问题标题】:URL structure not changing on godaddy网址结构在godaddy上没有改变
【发布时间】:2014-04-13 21:41:56
【问题描述】:

我的网址:http://example.com/index.php?L=F/12345678

这是我尝试过的。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)/?$ index.php?L=$1 [QSA,L]

这就是我所期望的:http://example.com/F/12345678 但没用。

【问题讨论】:

    标签: php regex apache .htaccess


    【解决方案1】:

    这应该可行:

    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^(GET|POST)\ /index\.php\?L=(.*)\ HTTP
    RewriteRule ^ /%2\? [R,L]
    
    #Internal rewrite
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?L=$1 [L]
    

    它应该将http://example.com/index.php?L=F/12345678 更改为http://example.com/F/12345678

    【讨论】:

    • @mwweb 你为什么要全大写?
    • 您需要在head标签中添加<base href="http://example.com/>。或者在所有图片链接之前添加/。您还可以编辑您的评论,使其不全部大写吗?
    • 我无法编辑我的评论,因为我编辑过一次。当我写评论时,大写锁定已打开:D。感谢您的帮助,现在我正在尝试添加 base href。谢谢
    • 这条线是什么意思 RewriteCond %{THE_REQUEST} ^(GET|POST)\ /index\.php\?L=(.*)\ HTTP
    • 它基本上说如果url包含index.php并且有参数?L=那么它将继续重写并在?L=之后添加任何内容到http://example.com
    【解决方案2】:

    尝试使用:

    RewriteEngine On
    RewriteRule ^([^/]*)$ /index.php?L=$1 [L]
    

    【讨论】:

    • “不起作用”对于确定原因没有丝毫帮助。如果您真的需要某人的帮助,您可能需要详细说明。
    • 感谢您的帮助。网址保持不变,没有任何改变。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-26
    • 1970-01-01
    • 2012-12-19
    • 2011-09-05
    • 2016-09-20
    相关资源
    最近更新 更多