我的服务器支持告诉我,我的htaccess URL重写导致了开销.我主要使用URL重写"更好"的URL(例如example.com/?foo=bar将是example.com/foo/bar左右).一般来说,在针对优化htaccess RewriteEngine时要记住哪些提示和技巧?
我在regexp上非常糟糕,但我正试图some/path/image.jpg摆脱http://somepage.com/some/...etc并尝试这种方法:
function removeDomain($string) {
return preg_replace("/http:\/\/.*\//", "", $string);
}
Run Code Online (Sandbox Code Playgroud)
它不起作用 - 据我所知它只是返回一个空白字符串.我该如何写这个正则表达式?
如何在WordPress网站上删除作者前缀,我已经做了一个快速谷歌,但只找到了我不想诉诸的htaccess重定向.
澄清我想转此:
http://www.domain.com/author/cameron/
进入这个
http://www.domain.com/cameron/
我不想使用任何类型的任何重定向,但我可以在functions.php文件中使用实际的PHP代码,因为我希望网站上所有使用作者内容的链接自动更新而不保留原始链接然后重定向到新的.
谢谢
我希望在请求以".aspx"结尾的URL时调用特定的处理程序"/ OldVideos".
我如何在app.yaml文件中使用它?
谢谢!
我在网上搜索了我的问题的答案而没有任何运气,所以她说:
我正在重做我的mod_rewrite用于搜索引擎优化目的,我希望所有网址都是小写的,例如:
http://BLAbla.com/
Run Code Online (Sandbox Code Playgroud)
变
http://bla.com/
Run Code Online (Sandbox Code Playgroud)
目前我的.htaccess看起来像这样:
RewriteEngine on
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule (.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule ([\w]*)/$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^([^/]+)/([^/]?)$ index.php?worker=$1¶ms=$2 [L]
Run Code Online (Sandbox Code Playgroud)
但是当我运行http:// localhost/site /我得到错误500.我只知道基本的reg ex,并且mod_rewrite非常有限,所以我不能在这里查看错误.如果我删除重写地图行,页面不会给出任何错误.我的服务器还是不支持重写映射?
关于.htaccess文件的任何其他评论都非常受欢迎:)
谢谢你的时间.
我开始建立一个个人网站,我希望它的布局看起来像
-------------------------------
- Page Header & Menus Go Here -
-------------------------------
- Main Contents -
-------------------------------
- Footers -
-------------------------------
Run Code Online (Sandbox Code Playgroud)
主要的问题是我希望它是一个单页面界面,其中主要内容加载和显示与AJAX和jQuery的组合,以产生一个很好的效果.但是,我当然希望将内容添加到书签并由搜索引擎编入索引.我已经浏览了单页界面宣言,它解释了实现这一目标的一些好方法,但我真的不想让我的网址像
http://www.mysite.com/index.php#!section=section1
http://www.mysite.com/index.php#!section=section2
当然,我想把它们重新编写为
http://www.mysite.com/section1
http://www.mysite.com/section2
我的问题是这种方法是否正确/可行,以及AJAX URL是否与URL重写兼容.不管怎样,Google会将哪些网址编入索引?
我正在创建简单的应用程序,某种投资组合.我听说在链接中有一个*.html后缀更好,因为当谷歌索引时它会让我获得更好的SEO结果...
无论如何,有没有办法修改默认路由/重写网址,以便我的链接看起来像这样(我使用的波兰语字对我的访问者来说是可读的):
domain.pl/index.html
domain.pl/kontakt.html
domain.pl/oferta.html
domain.pl/sklepy.html
Run Code Online (Sandbox Code Playgroud)
这些链接被转换为一个控制器(如HomeController),但{0} .html链接中的{0}将被用作动作名称?或者甚至更好,我想将{0}从Url映射到英文动作名称,如:
index.html = index action
kontakt.html = contact action
oferta.html = offer action
sklepy.html = shops action
Run Code Online (Sandbox Code Playgroud) 我想在nginx中创建以下url
comments.php?id=34
Run Code Online (Sandbox Code Playgroud)
变
/comments/34
/comments/34/
Run Code Online (Sandbox Code Playgroud)
我正在尝试这个,它的工作原理
rewrite ^/comments/$id/(.*)$ /comments.php?id=$1? last;
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何强制重定向comments.php?id = x到/ comments/id
我已启用mod_rewrite并使用.htaccess文件传递所有请求index.php.
如果我访问URL的
http://localhost/mysite
http://localhost/mysite/abc
Run Code Online (Sandbox Code Playgroud)
页面加载一次.
但是,如果我在路径中添加额外的部分,页面加载三次,我的css文件不包括在内:
http://localhost/mysite/abc/xyz
http://localhost/mysite/abc/xyz/ttt
Run Code Online (Sandbox Code Playgroud)
等等...
全部导致页面加载三次.我可以看到这一点,因为我index.php在Eclipse中设置了断点.
这是我的.htaccess档案:
<IfModule mod_rewrite.c>
RewriteEngine on
# Block access to "hidden" directories whose names begin with a period.
# Files whose names begin with a period are protected by the FilesMatch directive
# above.
RewriteRule "(^|/)\." - [F]
# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize(). …Run Code Online (Sandbox Code Playgroud) 我在magento网址重写管理中没有几个自定义网址。我需要检查URL重写管理中是否存在特定的目标路径。例如,如果我的目标路径是“ XXXX / YYYY / XYZ”,我如何检查URL重写管理中是否存在该目标路径?
url-rewriting ×10
mod-rewrite ×3
.htaccess ×2
php ×2
ajax ×1
apache ×1
asp.net ×1
asp.net-mvc ×1
iis-7 ×1
lowercase ×1
magento ×1
nginx ×1
preg-replace ×1
regex ×1
seo ×1
wordpress ×1
yaml ×1