Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 新格式的url_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Apache 新格式的url

Apache 新格式的url,apache,.htaccess,mod-rewrite,url-rewriting,Apache,.htaccess,Mod Rewrite,Url Rewriting,下面给出的是我的.htaccess文件。它在localhost apache(www是C:/apache/www上的根目录)“url”是目录,我想要这样的输出 到 我更改windows主机文件127.0.0.1 localhost &还可以在httpd.conf文件中启用mod_重写&AllowOverride none到AllowOverride All &根目录到C:/apache/www //==============================HTaccess=========

下面给出的是我的.htaccess文件。它在localhost apache(www是C:/apache/www上的根目录)“url”是目录,我想要这样的输出

我更改windows主机文件127.0.0.1 localhost &还可以在httpd.conf文件中启用mod_重写&AllowOverride none到AllowOverride All &根目录到C:/apache/www

//==============================HTaccess==================================//
 Options:
# -MultiViews: Turns off multiviews so it doesn't interfer with our rewrite rules
# -Indexes: Stop directory listings
# +FollowSymlinks: Let out rewrite rules work

Options -MultiViews -Indexes +FollowSymlinks

<IfModule mod_security.c>
    # Turn off mod_security filtering.
    # SecFilterEngine Off

    # The below probably isn't needed, but better safe than sorry.
    SecFilterScanPOST Off
</IfModule>

ErrorDocument 404 /url/404.php

<IfModule mod_php5.c>
    php_value register_globals 0
    php_value magic_quotes_gpc 0
    php_value session.auto_start 0
    php_value safe_mode 0
</IfModule>

<IfModule sapi_apache2.c>
    php_value register_globals 0
    php_value magic_quotes_gpc 0
    php_value session.auto_start 0
    php_value safe_mode 0
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /url/
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?username=$1

#RewriteRule ^view-content/([^/]*)/([^/]*)\.html$ content.php?pageid=$1&title=$2 [L]

</IfModule>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE application/x-javascript text/css text/html text/xml
</IfModule>
//==============================HTaccess==================================//
/====================================================HTaccess==================================//
选项:
#-多视图:关闭多视图,这样就不会干扰我们的重写规则
#-索引:停止目录列表
#+以下语法链接:让重写规则发挥作用
选项-多视图-索引+FollowSymlinks
#关闭mod_安全过滤。
#分离过滤器发动机关闭
#下面的内容可能不需要,但安全总比抱歉好。
secfilters可以关闭
ErrorDocument 404/url/404.php
php\u值寄存器\u全局0
php\u值魔法\u引号\u gpc 0
php_值session.auto_启动0
php_值安全模式0
php\u值寄存器\u全局0
php\u值魔法\u引号\u gpc 0
php_值session.auto_启动0
php_值安全模式0
重新启动发动机
重写基/url/
重写规则^([a-zA-Z0-9_-]+)$index.php?用户名=$1
重写规则^([a-zA-Z0-9_-]+)/$index.php?用户名=$1
#重写规则^view content/([^/]*)/([^/]*)\.html$content.php?pageid=$1&title=$2[L]
AddOutputFilterByType DEFLATE应用程序/x-javascript文本/css文本/html文本/xml
//=================================================HTaccess==================================//
请告诉我怎么办?

试试这个:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /url/
RewriteCond %{QUERY_STRING} username\=(.*)
RewriteRule index\.php$ /url/%1

重新启动发动机
重写基/url/
RewriteCond%{QUERY\u STRING}用户名\=(.*)
重写规则索引\.php$/url/%1

希望这能帮助你……:)

如果确实要将
/url/index.php?username=shah
的请求从外部重定向到
/url/shah
,请尝试以下规则:

RewriteCond %{QUERY_STRING} ^(([^&]*&)*?)username=([^&]+)&*(.*)
RewriteRule ^index\.php$ /url/%3?%1%4 [L,R=301]
否则,对于反向:

RewriteCond $0 !=index.php
RewriteRule ^[^/]+$ index.php?username=$0 [L,QSA]

你能解释一下到底是什么不起作用吗?这仅仅是重写规则还是整个.htaccess文件被忽略?请阅读下面的回答上面的示例重定向到未找到的页面你能告诉我它重定向了哪个url吗?谢谢,您的代码正在工作,但页面未在本地找到其正在更改的url&显示未找到的页面。Online phpprojects.netau.net/url/index.php?username=hereusername无任何内容仅显示querystring我的代码正在工作index.php?username=shah&现在我想知道有关此问题的信息,请重写规则^view content/([^/]*)/([^/]*)\.html$content.php?pageid=$1&title=$2[L]为什么这不起作用