从的.htaccess URL +目录中删除WWW(.htaccess Remove WWW from URL + Directories)

   IT问题网   2019-04-01 00:00:00

问 题

这似乎是一个非问题对许多人来说(读:我无法找到答案),但我想更新下的htaccess code,不仅从url中删除了"www"的,但也可以是任何子目录被访问的

rewriteengine叙述上
的rewritecond%{http_host} ^ www \。(。+)$ [nc]
重写规则^ $ http(*)://%1 / $ 1 [r = 301,l]
 

通过这个, http://www.example.com/any/ 解决很好,但我想它重定向到 http://example.com/any/ 与根。

解决方案

我有同样的问题(麻烦从指向一个子目录上的附加域网址剥离'www'),但一些试验后错误,这似乎为我工作:

rewriteengine叙述上
的rewritecond%{http_host} ^ www \。(。*)$ [nc]
重写规则^ $ http(*)://%1%{request_uri} [r = 301,qsa,nc,l]
 

例如:<一href="http://www.addondomain.com/projects/a/gallery/4/2">http://www.addondomain.com/projects/a/gallery/4/2 - > <一个href="http://addondomain.com/projects/a/gallery/4/2">http://addondomain.com/projects/a/gallery/4/2

标签:目录删除



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

通过字preSS或改写的.htaccess URL重写(URL rewriting via Wordpress Rewrite or .htaccess)

problem jump to edit8 to see how i solved this let's s ...

如何阻止多个mod_rewrite的通行证(或无限循环)在htaccess的背景下(How to block multiple mod_rewrite passes (or infinite loops) in a .htaccess context)

problem i'm working on a website running on a ...

Zend框架和Word preSS集成(Zend Framework and Wordpress Integration)

problem we have an existing zend framework site hosted at ...

如何删除&QUOT;网络/ app_dev.php&QUOT;从Symfony2的网址?(How to remove &quot;web/app_dev.php&quot; from Symfony2 URLs)

problem i just created my first symfony2 project. but the ...

通过301重定向404误差的.htaccess的搜索引擎优化等(Redirecting 404 error with .htaccess via 301 for SEO etc)

problem i couldn't find a straight answer to my question ...

而不进行任何验证的IP地址(Allow IP address without authentication)

problem i have set up a site that is currently work in pr ...

HTTP的当量=英寸×UA兼容&QUOT;内容=IE =边缘,镀铬= 1......在.htaccess把这个?(http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge,chrome=1&quot; ... Putting this in .htaccess)

problem i downloaded html5 boilerplate and it wouldnt val ...

如何使用mod_headers中和mod_expires缓存(how to use mod_headers and mod_expires to cache)

problem i want to cache images and other files on my site ...

如何从一个子目录中删除的.htaccess密码保护(How to remove .htaccess password protection from a subdirectory)

problem i have password protected my entire website using ...

请.git目录网站无法访问(Make .git directory web inaccessible)

problem i have a website that i use github (closed source ...

重写URL以htaccess的(rewrite url with htaccess)

problem first of all i am a beginner so please answer in ...

重写QUOT&; pretty的网址&QUOT;?(Rewrite to &quot;pretty URL&quot;)

problem this is an example of what i am trying to achieve ...

需要mod_rewrite的URL信息(mod_rewrite URL info required)

problem i am new to this mod_rewrite. i have been success ...

的.htaccess,迫使斜线和www(.htaccess, forcing a slash and www)

problem can someone please help me to force my website to ...

简单的301重定向在.htaccess与查询字符串不以重定向指令工作(Simple 301 redirect in .htaccess with query string does not work with Redirect directive)

problem i am trying to redirect a single url in a .htacce ...

如何将文本转换使用的.htaccess为小写的网址(How to convert text to lowercase URLs using .htaccess)

problem i want to set up 301 redirects in my .htaccess fi ...

&QUOT;双向&QUOT;改写(&quot;Two Way&quot; Rewrite)

problem so, i'm trying to accomplish this: we have a url ...

与字preSS除非使用URL重写不工作[R](Url rewriting not working with wordpress unless using [R])

problem i have a wordpress installation on my website on ...

通过htaccess的重定向所有的HTTP和HTTPS非www网址https://www.xyz.com(Redirect all http AND https non-www URLS to https://www.xyz.com via htaccess)

problem for reasons much too long and complex to get into ...

重定向的* .htm为* .PHP(Redirect *.htm to *.php)

problem i am trying find out how to redirect all traffic ...