简体   繁体   English

如何替换所有? 和=通过/ htaccess

[英]how to replace all the ? and = by / htaccess

hello all i have a site in which i would like to replace all the ? 您好,我有一个要替换所有网站的网站吗? and = of urls by / . 和=由/组成的网址。 i know this cn be done by htaccess file but i am very new to htaccess 我知道这个cn是由htaccess文件完成的,但是我对htaccess非常陌生

i have this code in my htaccess file 我的htaccess文件中有此代码

ErrorDocument 404 /error404.php
ErrorDocument 403 /error404.php
 Options -Indexes 
 RewriteEngine On
 RewriteBase /

  RewriteCond %{REQUEST_METHOD} POST [NC]
  RewriteRule ^ - [L]

 RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.*$ [NC] 
  RewriteRule \.(gif|jpg|jpeg)$ http://www.domain.com [L]

  RewriteCond %{HTTP_HOST} !^www\.
 RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

  RewriteCond %{THE_REQUEST} \s/+(page1)\.php\?eid=(78)[&\s] [NC]
  RewriteRule ^ /%1/%2? [R=301,L]
   RewriteRule ^(page1)/(\d+)$ /$1.php?eid=$2 [L,QSA,NC]

     RewriteCond %{THE_REQUEST} \s/+page2\.php\?url=([^\s&]+) [NC]
   RewriteRule ^ /%1? [R=301,L]

     RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
     RewriteRule ^ /%1 [R=302,L,NE]

     RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
 RewriteRule ^(.+?)/?$ /$1.php [L]

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

thnkx in advance ... i wana replace all the ? 提前thnkx ...我要替换所有? and = of the url by / like 和/的网址=

    domain.com/page.php?id=44 by 
    domain.com/page/id/4

First off, you need to clarify what you intend to accomplish. 首先,您需要阐明要完成的工作。

If you intend to have the user visit domain.com/page/id/4 and have it internally be rewritten to page.php?id=4 , then you have two options: 如果您打算让用户访问domain.com/page/id/4并在内部将其重写为page.php?id=4 ,那么您有两种选择:

1) use a rewrite rule, such as: 1)使用重写规则,例如:

RewriteRule ^/?page/([^/]+)/(.+)$ page.php?$1=$2

2) (preferred) use MultiViews and have your php script do the logic for you by parsing the 2)(首选)使用MultiViews,并让您的php脚本通过解析

REQUEST_URI ($_SERVER['REQUEST_URI']).

First off, you need to clarify what you intend to accomplish. 首先,您需要阐明要完成的工作。

If you intend to have the user visit domain.com/page/id/4 and have it internally be rewritten to page.php?id=4, then you have two options: 如果您打算让用户访问domain.com/page/id/4并将其内部重写为page.php?id = 4,那么您有两种选择:

1) use a rewrite rule, such as: 1)使用重写规则,例如:

RewriteRule ^/?page/([^/]+)/(.+)$ page.php?$1=$2 2) (preferred) use MultiViews and have your php script do the logic for you by parsing the RewriteRule ^ /?page /([[^/]+)/(.+)$ page.php?$ 1 = $ 2 2)(首选)使用MultiViews,并让您的php脚本通过解析

REQUEST_URI ($_SERVER['REQUEST_URI']). REQUEST_URI($ _SERVER ['REQUEST_URI'])。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM