Onclick url重写

时间:2013-07-22 13:21:45

标签: php .htaccess url-rewriting

我有一个我想重写的网址,因为来自noob开发者的编程错误。

php

$branch = "lwh/main/"; // Dirs in URL from host to main folder
$pagebranch = "lwh/"; // URL branch for hyperlinks
$apages = "account/";
$bpages = "booking/";
$gpages = "general/";
$ppages = "product/";

功能 //全局函数

function fetchdir($dir)     
{
   $protocol = $GLOBALS['protocol'];
    $host = $GLOBALS['host'];
    ($dir == $GLOBALS['apages'] || $dir == $GLOBALS['bpages'] || $dir == $GLOBALS['ppages'] || $dir == $GLOBALS['gpages'] ? $branch = $GLOBALS['pagebranch'] : $branch = $GLOBALS['branch']);
    echo $protocol.$host.$branch.$dir;
}

function fetchinline($dir)      
{   
    $protocol = $GLOBALS['protocol'];
    $host = $GLOBALS['host'];
    ($dir == $GLOBALS['apages'] || $dir == $GLOBALS['bpages'] || $dir == $GLOBALS['ppages'] || $dir == $GLOBALS['gpages'] ? $branch = $GLOBALS['pagebranch'] : $branch = $GLOBALS['branch']);
    return $protocol.$host.$branch.$dir;
}

所以我说我在general folder

中有index.php,about.php
<a href="<?php fetchdir($gpages); ?>index.php">Home</a>
<a href="<?php fetchdir($gpages); ?>contact.php">Home</a>

但问题在于网址

http://www.urltest.x10.mx/lwh/general/index.php
http://www.urltest.x10.mx/lwh/booking/car.php

我的问题 如何重写网址,以便当您点击general folder中的任何链接时,它就像是   http://www.urltest.x10.mx/index.php

并在booking folder中就像http://www.urltest.x10.mx/booking/car.php

一样

我想在点击任何链接时重写网址。

我试过 * 在我的根目录 *

Options +FollowSymlinks
RewriteEngine on

RewriteCond $1 !^lwh/
RewriteRule (.*) /lwh/main/pages/general/$1 [L]

RewriteCond %{REQUEST_URI} !^lwh/
RewriteRule ^(.*)$ lwh/$1 [L]

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



AuthName "root"
AuthType Basic
require valid-user
Options -Indexes

lwh 文件夹中,我有

RewriteEngine on
RewriteBase /

RewriteRule ^general/(.*)$ lwh/main/pages/general/$1 [L]
RewriteRule ^account/(.*)$ lwh/main/pages/account/$1 [L]
RewriteRule ^booking/(.*)$ lwh/main/pages/booking/$1 [L]
RewriteRule ^product/(.*)$ lwh/main/pages/product/$1 [L]

RewriteRule ^$ lwh/main/pages/account/ [L]
RewriteRule ^$ lwh/main/pages/general/ [L]
RewriteRule ^$ lwh/main/pages/booking/ [L]
RewriteRule ^$ lwh/main/pages/product/ [L]

ErrorDocument 404 /lwh/main/pages/general/index.php
Options -Indexes
AuthName "main"

隐藏lwh文件夹,但当我点击链接时,我仍然会收到填充网址...

请有人帮忙

0 个答案:

没有答案