url中的奇怪字符 - 简单链接和mod_rewrite

时间:2011-07-29 13:03:40

标签: php regex apache url mod-rewrite

请参阅:http://test.shivimpanim.org

点击视频,动作,游戏或工具中的任何一个

注意如何将奇怪的字符附加到网址的末尾! 为什么?

在查尔斯嗤之以鼻,没有任何关于二次重定向的迹象......

这是我的.htaccess:

# Set up mod_rewrite
Options +FollowSymLinks
RewriteEngine on
#
# Rules follow

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R,L]

# Here we simply remap the name if it doesn't exist as a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^video$ /index.php?s=video [NC,L]
RewriteRule ^action$ /index.php?s=action [NC,L]
RewriteRule ^games$ /index.php?s=games [NC,L]
RewriteRule ^tools$ /index.php?s=tools [NC,L]
RewriteRule ^jplay$ /index.php?s=jplay [NC,L]
RewriteRule ^contact$ /index.php?s=contact [NC,L]

RewriteRule ^video/(.*) /index.php?s=video&p=$1 [NC,L]
RewriteRule ^action/(.*) /index.php?s=action&p=$1 [NC,L]
RewriteRule ^games/(.*) /index.php?s=games&p=$1 [NC,L]
RewriteRule ^tools/(.*) /index.php?s=tools&p=$1 [NC,L]
RewriteRule ^jplay/(.*) /index.php?s=jplay&p=$1 [NC,L]
RewriteRule ^contact/(.*) /index.php?s=contact&p=$1 [NC,L]

这是我的index.php:

<?php
$pageurl = $_REQUEST['p'];
$section = $_REQUEST['s'];

include_once('main_top.php');

echo($section);

include_once('main_bottom.php');

?>

这是我的main_top.php:

<?php 
    $top_menu_home = 'top_menu_home';
    $top_menu_store = 'top_menu_store';
    $top_menu_video = 'top_menu_video';
    $top_menu_action = 'top_menu_action';
    $top_menu_games = 'top_menu_games';
    $top_menu_tools = 'top_menu_tools';
    $top_menu_articles = 'top_menu_articles';
    $top_menu_jplay = 'top_menu_jplay';
    $top_menu_contact = 'top_menu_contact';

    switch($section) {
        case 'store': $top_menu_store .= '_selected'; break;
        case 'video': $top_menu_video .= '_selected'; break;
        case 'action': $top_menu_action .= '_selected'; break;
        case 'games': $top_menu_games .= '_selected'; break;
        case 'tools': $top_menu_tools .= '_selected'; break;
        case 'articles': $top_menu_articles .= '_selected'; break;
        case 'jplay':   $top_menu_jplay .= '_selected'; break;
        case 'contact': $top_menu_contact .= '_selected'; break;
        default: $top_menu_home .= '_selected'; break;
    }
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
        <link TYPE="text/css" rel="stylesheet" href="css/common.css" media="all"/>
        <link TYPE="text/css" rel="stylesheet" href="css/video.css" media="all"/>
        <link TYPE="text/css" rel="stylesheet" href="css/flexcroll.css" media="all"/>

        <script type='text/javascript' src="js/flexcroll.js"></script>
        <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
        <script type="text/javascript">
            var addthis_config = {
                data_track_clickback:true,
                data_track_addressbar:true,
                services_compact: "twitter, email, facebook, google, stumbleupon, digg, more",
                services_exclude: "print",
                ui_offset_left: -300
            };
        </script>
        <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4e07777b3143e5fb"></script>
    </head>
    <body>
        <ul id="top_menu">
            <a href="/"><li id="<?php echo($top_menu_home); ?>"><span>Home</span></li></a>
            <a href="/store"><li id="<?php echo($top_menu_store); ?>"><span>Store</span></li></a>
            <a href="/video"><li id="<?php echo($top_menu_video); ?>"><span>Video</span></li></a>
            <a href="/action"><li id="<?php echo($top_menu_action); ?>"><span>Action</span></li></a>
            <a href="/games"><li id="<?php echo($top_menu_games); ?>"><span>Games</span></li></a>
            <a href="/tools"><li id="<?php echo($top_menu_tools); ?>"><span>Tools</span></li></a>
            <a href="/articles"><li id="<?php echo($top_menu_articles); ?>"><span>Articles</span></li></a>
            <a href="/jplay"><li id="<?php echo($top_menu_jplay); ?>"><span>jPlay</span></li></a>
            <a href="/contact"><li id="<?php echo($top_menu_contact); ?>"><span>Contact</span></li></a>

            <form id="searchform" name="searchform" action="search.php">
                <img id="searchglass" src="menu/SEARCHGLASS.png" onclick="searchform.submit();"/>
                <input type="text" name="query" id="query" value="" />
            </form>
        </ul>

        <div class="clearfloat">&nbsp;</div>

        <div id="submenu">

            <div id="breadcrumbs" class="breadcrumbs_link">
                <a href="#">VIDEO</a> > <a href="#">QUESTIONS & ANSWERS</a>
            </div>

            <div class="clearfloat"></div>

            <div id="social">
                <!-- AddThis Button BEGIN -->
                <div class="addthis_toolbox addthis_default_style ">
                    <a class="addthis_counter addthis_pill_style"></a>
                </div>

                <!-- PlusOne Button BEGIN -->
                <div id="gp-container">
                    <g:plusone size="small"></g:plusone>
                </div>

                <!-- Facebook Button BEGIN -->
                <iframe src="http://www.facebook.com/plugins/like.php?app_id=147083741996431&amp;href&amp;send=false&amp;layout=button_count&amp;width=90&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=verdana&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe>
            </div>
        </div>

        <div class="clearfloat">&nbsp;</div>
        <br/>&nbsp;<br/>

这是main_bottom.php

</body>
</html>

1 个答案:

答案 0 :(得分:1)

而不是

<a href="/video"><li id="<?php echo($top_menu_video); ?>"><span>Video</span></li></a>

试试这个:

<li id="<?php echo($top_menu_video); ?>"><a href="/video"><span>Video</span></a></li>

有些时候,在特定浏览器中,由于li或输入标记,您的链接标记将无效。

相关问题