0

For a new site we are developing, the URL structure is as follows.

After everything is finished, now the *client wants to change the URL structure as follows

How can i change this as per his requirements with mod_rewrite / htaccess? I am not an expert with htaccess and its not possible for us to change the platform now.

4

3 回答 3

0

尝试这样的事情:

RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ $1?$2/$3 [L,QSA]
RewriteRule (.*?)/?$ index.php?$1 [L,QSA]
于 2012-05-29T14:33:46.430 回答
0

通过启用 mod_rewrite 和 .htaccess httpd.conf,然后将此代码放在您.htaccessDOCUMENT_ROOT目录下:

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]

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?$1=$2/$3 [L,QSA]

RewriteRule (.*?)/?$ index.php?$1 [L,QSA]
于 2012-05-29T14:38:57.570 回答
0

htaccess 示例

<IfModule mod_rewrite.c>
    RewriteEngine On

    # About Us ---------------------------------------
    RewriteRule ^aboutus.html*$ index.php?page=aboutus [L]

</IfModule>

mod重写php示例

function replace_for_mod_rewrite($s) {
$siteUrl = "Your site url";
$urlin = array( "`".$siteUrl."/index\.php\?page=aboutus(['|\"|#])`is" );
$urlout = array( $siteUrl."/aboutus.html\\1" );
$s = preg_replace($urlin, $urlout, $s);
}

更多详情:TechNew.In

于 2012-05-29T14:47:17.507 回答