Php 搜索引擎优化友好的URL重定向到404错误

Php 搜索引擎优化友好的URL重定向到404错误,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我有一个用户可以注册的注册页面。注册后,他们将被重定向到他们的个人资料。重定向为:example.com/profiles/?id=[SOME id]。这是可行的,但在我将.htaccess中的URL更改为SEO友好的URL后,用户会被重定向到404页面错误,其中找不到他们的个人资料。实际上,在example.com/profiles?id=[SOME id]中键入时,他们的配置文件确实存在,但在example.com/profiles/[SOME id]中,它表示配置文件不存在。这是我的.ht

我有一个用户可以注册的注册页面。注册后,他们将被重定向到他们的个人资料。重定向为:example.com/profiles/?id=[SOME id]。这是可行的,但在我将.htaccess中的URL更改为SEO友好的URL后,用户会被重定向到404页面错误,其中找不到他们的个人资料。实际上,在example.com/profiles?id=[SOME id]中键入时,他们的配置文件确实存在,但在example.com/profiles/[SOME id]中,它表示配置文件不存在。这是我的.htaccess

        <IfModule mod_deflate.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
Options -Multiviews
RewriteEngine on

RewriteCond %{THE_REQUEST} /profiles/(?:index\.php)?\?id=([^&\s]+) [NC]
RewriteRule ^ /profiles/%1? [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^profiles/([^/]+)/?$ /profiles/index.php?id=$1 [NC,L]
#Remove .php
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>

重写cond%{REQUEST_FILENAME}-D
RewriteCond%{REQUEST_FILENAME}.php-f
选项-多视图
重新启动发动机
RewriteCond%{THE_REQUEST}/profiles/(?:index\.php)?\?id=([^&\s]+)[NC]
是否重写规则^/profiles/%1?[左,右]
重写cond%{REQUEST_FILENAME}-F
重写规则^profiles/([^/]+)/?$/profiles/index.php?id=$1[NC,L]
#Remove.php
RewriteCond%{REQUEST_FILENAME}.php-f
重写规则^(.*)/?$/$1.php[L]
SetOutputFilter放气
#Netscape 4.x有一些问题。。。
浏览器匹配^Mozilla/4 gzip纯文本/html
#网景4.06-4.08还有一些问题
浏览器匹配^Mozilla/4\.0[678]无gzip
#MSIE伪装成网景,但它很好
#BrowserMatch\bMSIE!没有gzip!仅限gzip文本/html
#注意:由于Apache 2.0.48之前的mod_setenif中存在错误
#上面的正则表达式不起作用。您可以使用以下命令
#获得所需效果的变通方法:
浏览器匹配\bMSI[E]!没有gzip!仅限gzip文本/html
#不要压缩图像
SetEnvIfNoCase请求_URI。(:gif | jpe?g | png)$no gzip不变
#确保代理不会提供错误的内容
标头附加变量用户代理env=!不要改变

动态索引文件是example.com/profiles/,其中profiles文件夹有一个index.php。通过使用.htaccess消除index.php。如何使example.com/profiles/[SOME ID]返回实际的配置文件而不是404错误?

@starkeen它位于我网站的根文件夹中