mod-rewrite

htaccess add www if not subdomain, if subdomain remove www

纵然是瞬间 提交于 2020-01-02 06:32:22
问题 I'm trying to make this - probably example would be the best, so: domain.com -> www.domain.com www.domain.com -> www.domain.com subdomain.domain.com -> subdomain.domain.com www.subdomain.domain.com -> subdomain.domain.com So if visitor is in subdomain, don't add www and when is set, remove It. Else if not in subdomain, add www. I tried to write something like this, but this doesn't remove www from subdomain adress :/ Also, if possible, I don't want to use domain and TLD domains but make it as

htaccess add www if not subdomain, if subdomain remove www

為{幸葍}努か 提交于 2020-01-02 06:31:08
问题 I'm trying to make this - probably example would be the best, so: domain.com -> www.domain.com www.domain.com -> www.domain.com subdomain.domain.com -> subdomain.domain.com www.subdomain.domain.com -> subdomain.domain.com So if visitor is in subdomain, don't add www and when is set, remove It. Else if not in subdomain, add www. I tried to write something like this, but this doesn't remove www from subdomain adress :/ Also, if possible, I don't want to use domain and TLD domains but make it as

Remove part of a URL

安稳与你 提交于 2020-01-02 04:37:26
问题 How can I remove main/ in http://domain/main/about so the URL will be like this http://domain/about Thanks 回答1: Well, in the absence of any further details, you could try something like this: RewriteRule (.*)/main/(.*) $1/$2 But this is a VERY broad rule - you'd probably want to tune it more tightly than that. Try turning the RewriteLogLevel to 9 and watching the rules as they get processed so you can get a better idea of what is being matched. 回答2: If you only need one file to be rewritten :

Exclude certain subfolders and domains in redirects

强颜欢笑 提交于 2020-01-01 19:58:26
问题 This is a continuation from Redirect only HTML files? How can I change my .htaccess to make it exclude certain subfolders or subdomains from the HTML-only redirect? I tried doing using this code to exclude the 'downloads' subfolder and the 'dev' and 'support' subdomains, but it didn't work: RewriteCond %{HTTP_HOST} ^pandamonia.us$ [OR] RewriteCond %{HTTP_HOST} ^www.pandamonia.us$ [OR] RewriteCond %{HTTP_HOST} !download [OR] RewriteCond %{HTTP_HOST} !faq RewriteCond %{HTTP_HOST} !support [OR]

Apache mod_rewrite ending periods

旧时模样 提交于 2020-01-01 19:03:05
问题 I am trying to better understand Apache's mod_rewrite, and am having unexpected results. I've tried many different expressions, but nothing seems to behave how I understand it should. RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?route=$1 [QSA,L] Using www.domain.com/item1/item2/item3 yields item1/item2/item3 Using www.domain.com/item1/item2/item3.php yields item1/item2/item3.php Using

How to handle mod-rewrite with a custom url scheme?

不问归期 提交于 2020-01-01 19:01:13
问题 So here's my problem : I'm trying to do a redirection on a webpage with the htaccess file. This redirection will be towards a custom URL (i.e not something ike "http://..." but something like "myurl://...). For now, I'm trying this on a little local apache server, in which I have a index.html page, a "test" directory and in this directory a .htaccess file and a test.html file. Here's what's inside the .htaccess file : Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^(.*)$

mod_rewrite: Redirect request to subdir with many subfolders of different structures + redirect to index.php

一世执手 提交于 2020-01-01 16:32:25
问题 I need to create a following rule to place in my .htaccess For each request i'd like to execute file/path in subfolder subdir. If the file doesn't exist there then i'd like to forward this request to index.php Let say that .htaccess iw placed at http://domain/folder When the user opens url http://domain/folder/Subfolder/xxx.html he should recieve file from http://domain/folder/subdir/Subfolder/xxx.html So these rules have to consider the fact that there are subfolders inside subdir.

preventing direct download of SQLite file using .htaccess

梦想与她 提交于 2020-01-01 14:42:55
问题 I know the basics of .htaccess, but freely admit to being a non-expert when it comes to mod_rewrite. The problem: I have a sqlite db file in the document root (no, I can't move it out of here) called data.sqlite . This file is accessed internally by PHP files, however, I want to protect this file from being 'downloaded' by the user typing the db URL directly into their browser. I have used .htaccess to create pretty URLs in the past, and thought using mod_rewrite would provide a nice solution

mod_rewrite rule to enforce canonical percent-encoding

亡梦爱人 提交于 2020-01-01 14:23:06
问题 We have a PHP app with a dynamic URL scheme which requires characters to be percent-encoded, even "unreserved characters" like parentheses or aphostrophes which aren't actually required to be encoded. URLs which the app deems to be encoded the "wrong" way are canonicalized and then redirected to the "right" encoding. But Google and other user agents will canonicalize percent-encoding/decoding differently, meaning when Googlebot requests the page it will ask for the "wrong" URL, and when it

PHP , htaccess: apply page title in URL

自作多情 提交于 2020-01-01 14:20:18
问题 I want to apply the page HTML title in the URL for example in here (stackoverflow) the url is something like that: http://stackoverflow.com/questions/10000000/get-the-title-of-a-page-url you can see the "get-the-title-of-a-page-url" part which is the page title what i mean is when the user go to spowpost.php?post=1 the actual url that shows up when the pages load will be spowpost.php?post=1$title=..the_title.. how can i do that? EDIT: i was thinking about htaccess , but i don't know this very