SEO URL仅适用于特定情况

时间:2016-06-28 04:23:21

标签: php apache .htaccess mod-rewrite

我有一个用户可以注册的注册页面。注册后,他们将被重定向到他们的个人资料。重定向是:example.com/profiles/?id=[SOME ID]。修改.htaccess文件后,我将其设为example.com/profiles/?id=[SOME ID]成为example.com/profiles/[SOME ID]。这是我的完整.htaccess文件:

 <IfModule mod_deflate.c>
Options -Multiviews
RewriteEngine on

RewriteCond %{THE_REQUEST} /profiles/?\?id=([^&\s]+) [NC]
RewriteRule ^ /profiles/%1? [L,R]
RewriteRule ^(?:profiles/)?([0-9]+)/?$ /profiles/?id=$1 [L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]
    SetOutputFilter DEFLATE
    <IfModule mod_setenvif.c>
        # Netscape 4.x has some problems...
        BrowserMatch ^Mozilla/4 gzip-only-text/html

        # Netscape 4.06-4.08 have some more problems
        BrowserMatch ^Mozilla/4\.0[678] no-gzip

        # MSIE masquerades as Netscape, but it is fine
        # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

        # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
        # the above regex won't work. You can use the following
        # workaround to get the desired effect:
        BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

        # Don't compress images
        SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
    </IfModule>
    <IfModule mod_headers.c>
        # Make sure proxies don't deliver the wrong content
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
</IfModule>

每当我输入example.com/profiles/48时,它会被重定向到404错误,当它应该存在时。但是,当我输入example.com/profiles/index.php/48时,它会起作用,并且用户会被重定向到他们的个人资料。我怎样才能删除index.php?因此,网址如下所示:example.com/profiles/48

0 个答案:

没有答案