.htaccess与php GET

.htaccess与php GET,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,我有一个非常简单的要求 必须删除所有.php扩展名,并删除我的GET请求URL http://domain.com/product.php?name=<product_name> 当我这样做时,所有的.php和.html扩展都被删除了,但是获取页面css和js被破坏了 我也试过: RewriteRule ^([A-Za-z]+)/?$ product.php?name=$1 [L] 然后显示.php扩展名,或者转到GET请求页面 我不熟悉.htaccess。现

我有一个非常简单的要求

必须删除所有.php扩展名,并删除我的GET请求URL

http://domain.com/product.php?name=<product_name> 
当我这样做时,所有的.php和.html扩展都被删除了,但是获取页面css和js被破坏了

我也试过:

RewriteRule    ^([A-Za-z]+)/?$    product.php?name=$1    [L]
然后显示.php扩展名,或者转到GET请求页面

我不熟悉.htaccess。现在用它打碎我的头

尝试以下操作:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule    ^home/?$    index.php    [NC,L]
RewriteRule    ^product/([A-Za-z]+)/?$    product.php?name=$1    [L]

RewriteRule ^([^\.]+)$ $1.php
RewriteRule ^([^\.]+)$ $1.html [NC,L]
<IfModule mod_rewrite.c>
    Options +FollowSymLinks -MultiViews
    # Turn mod_rewrite on
    RewriteEngine On
    RewriteBase /

    ## If the request is for a valid directory
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    ## If the request is for a valid file
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    ## If the request is for a valid link
    RewriteCond %{REQUEST_FILENAME} -l
    ## don't do anything
    RewriteRule ^ - [L]

    # if requested files exists in /public then forward it there
    RewriteCond %{DOCUMENT_ROOT}/public/$1 -f
    RewriteRule ^(.+?)/?$ /public/$1 [L]

    # if requested files doesn't exist in /public then forward it to requested php file
    RewriteCond %{DOCUMENT_ROOT}/$1 !-f
    RewriteRule ^(.+?)/?$ %{REQUEST_FILENAME}.php [L]
</IfModule>

选项+以下符号链接-多视图
#打开mod_rewrite
重新启动发动机
重写基/
##如果请求的是有效目录
RewriteCond%{REQUEST_FILENAME}-d[或]
##如果请求是针对有效文件的
RewriteCond%{REQUEST_FILENAME}-f[或]
##如果请求是针对有效链接的
RewriteCond%{REQUEST_FILENAME}-l
##什么都不要做
重写规则^-[L]
#如果请求的文件存在于/public中,则将其转发到那里
重写cond%{DOCUMENT_ROOT}/public/$1-f
重写规则^(+?)/?$/public/$1[L]
#如果请求的文件在/public中不存在,则将其转发到请求的php文件
重写cond%{DOCUMENT_ROOT}/$1-F
重写规则^(+?)/?$%{REQUEST_FILENAME}.php[L]
尝试以下操作:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule    ^home/?$    index.php    [NC,L]
RewriteRule    ^product/([A-Za-z]+)/?$    product.php?name=$1    [L]

RewriteRule ^([^\.]+)$ $1.php
RewriteRule ^([^\.]+)$ $1.html [NC,L]
<IfModule mod_rewrite.c>
    Options +FollowSymLinks -MultiViews
    # Turn mod_rewrite on
    RewriteEngine On
    RewriteBase /

    ## If the request is for a valid directory
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    ## If the request is for a valid file
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    ## If the request is for a valid link
    RewriteCond %{REQUEST_FILENAME} -l
    ## don't do anything
    RewriteRule ^ - [L]

    # if requested files exists in /public then forward it there
    RewriteCond %{DOCUMENT_ROOT}/public/$1 -f
    RewriteRule ^(.+?)/?$ /public/$1 [L]

    # if requested files doesn't exist in /public then forward it to requested php file
    RewriteCond %{DOCUMENT_ROOT}/$1 !-f
    RewriteRule ^(.+?)/?$ %{REQUEST_FILENAME}.php [L]
</IfModule>

选项+以下符号链接-多视图
#打开mod_rewrite
重新启动发动机
重写基/
##如果请求的是有效目录
RewriteCond%{REQUEST_FILENAME}-d[或]
##如果请求是针对有效文件的
RewriteCond%{REQUEST_FILENAME}-f[或]
##如果请求是针对有效链接的
RewriteCond%{REQUEST_FILENAME}-l
##什么都不要做
重写规则^-[L]
#如果请求的文件存在于/public中,则将其转发到那里
重写cond%{DOCUMENT_ROOT}/public/$1-f
重写规则^(+?)/?$/public/$1[L]
#如果请求的文件在/public中不存在,则将其转发到请求的php文件
重写cond%{DOCUMENT_ROOT}/$1-F
重写规则^(+?)/?$%{REQUEST_FILENAME}.php[L]

.htaccess
文件中使用此选项:

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

在测试之前,请确保清除缓存,它会给您留下URL:
http://domain.com/product/

.htaccess
文件中使用此选项:

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

在测试之前,请确保清除缓存,它会给您留下URL:
http://domain.com/product/

在get页面中提供js和css的完整URL。是的,我正在考虑使用。这管用!但我不知道这样做/使用是否正确!在你的get页面中提供js和css的完整URL。是的,我正在考虑使用。这管用!但我不知道这样做/使用是否正确!尝试了你的/public代码的第一部分-不工作尝试了你的/public代码的第一部分-不工作css/JS/img的中断!CSS/JS/img的休息!