mod-rewrite

htaccess rewrite rules to remove multiple subfolders from a URL

▼魔方 西西 提交于 2020-03-23 02:07:22
问题 Due file system sub-directory constraints I will most likely reach I want to separate the /users folder into /users/a/username , /users/b/username , /users/c/username , etc. So the data on the server for a user would be in: www.domain.com/users/a/username/ , www.domain.com/users/b/username /, etc I want the URL to be: www.domain.com/users/username/ Optionally to avoid duplicate content a 301 redirect from www.domain.com/users/a/username/ to www.domain.com/users/username/ would also be good.

Rewrite to append to query string

若如初见. 提交于 2020-03-21 19:54:07
问题 I don't understand why I always have such a massive problem with rewrite rules, but I simply want to append to the query string if it exists and add a ? if it does not. I actually don't care if the URL is changed in the browser or not -- it just has to load the correct target page. RewriteRule /cia16(.*)\?(.*) /cia$1?$2&CIA=16 RewriteRule /cia16(.*) /cia/$1?CIA=16 If I go to /cia16/steps.php?page=1 it actually gets rewritten to /cia/steps.php?CIA=16 -- that is it seems accept the query string

.htaccess point a subdomain to a directory

时间秒杀一切 提交于 2020-03-21 06:59:04
问题 I have the following directory structure: site.com/ - index.php - desktop/ -- index.php - mobile/ -- index.php The index.php of site.com redirects to desktop/index.php or mobile/index.php, depending of user platform. The problem is that I need different subdomains to point to respective directories: mobile.site.com -> site.com/mobile desktop.site.com -> site.com/desktop My application also uses rewrite to make SEO friendly URL's, so I need: mobile.site.com/login -> site.com/mobile/login

Explain htaccess rules?

情到浓时终转凉″ 提交于 2020-03-19 05:29:12
问题 I have made this .htaccess file over the last hour through searching, copy and pasting etc. It does work how I want it to. However I do not understand it. Could someone please put it down step by step what is happening here in layman's terms for me. RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^/?(.*)$ /$1.php [L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php RewriteRule ^/?(.*

Explain htaccess rules?

泪湿孤枕 提交于 2020-03-19 05:29:08
问题 I have made this .htaccess file over the last hour through searching, copy and pasting etc. It does work how I want it to. However I do not understand it. Could someone please put it down step by step what is happening here in layman's terms for me. RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^/?(.*)$ /$1.php [L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php RewriteRule ^/?(.*

mod_rewrite with name replacing ID

ε祈祈猫儿з 提交于 2020-03-05 09:46:34
问题 I have a page on my website that dynamically displays content. The URL structure is mywebsite.com/giveaway/giveaway.php?id=(any number) I wish to change that dynamic URL into a static/friendly URL mywebsite.com/giveaway/name-of-giveaway-corresponding-to-id . In my .htaccess file found in my root folder i have the following: RewriteEngine On # external redirect from actual URL to pretty one RewriteCond %{THE_REQUEST} \s/+\?page=([^\s&]+) [NC] RewriteRule ^ /page/%1? [R=301,L] # existing rule

Htaccess mod_rewrite blocking my css

吃可爱长大的小学妹 提交于 2020-03-05 06:58:08
问题 Got htaccess rewriting my links for better seo like this: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} .*/([^/]+)/? [NC] RewriteCond %{REQUEST_URI} !index\.php [NC] RewriteRule .* /index.php?cat=%1 [L,NC,QSA] which rewrites http://www.example.com/any/number/of/directories/lastDir to: http://www.example.com/index.php?cat=lastDir but my css isnt working, when i upload htaccess to the server, there is just plain text without images and css tried

Htaccess mod_rewrite blocking my css

放肆的年华 提交于 2020-03-05 06:58:07
问题 Got htaccess rewriting my links for better seo like this: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} .*/([^/]+)/? [NC] RewriteCond %{REQUEST_URI} !index\.php [NC] RewriteRule .* /index.php?cat=%1 [L,NC,QSA] which rewrites http://www.example.com/any/number/of/directories/lastDir to: http://www.example.com/index.php?cat=lastDir but my css isnt working, when i upload htaccess to the server, there is just plain text without images and css tried

Edit Cookie HttpOnly value

不想你离开。 提交于 2020-03-03 07:28:10
问题 Due to PCI regulations, most cookies in my application need to be secure and httponly. I have achieved that through this line in my Apache config file: Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure However this breaks part of the application where a single cookie, let's call it foobar, must be read by javascript. Therefore I need to remove the httponly for this cookie only. I've played around with several approaches including mod_rewrite but I can't get the httponly to drop off the cookie.

.htaccess - won't add www to only one subdirectory

纵然是瞬间 提交于 2020-02-25 07:36:16
问题 I have a .htaccess in root directory, with this content: <IfModule mod_rewrite.c> RewriteEngine on #RewriteCond %{HTTP_HOST} ^domain.com #RewriteRule (.*) http://www.domain.com$1 [R=301,L] </IfModule> If I go to http://domain.com/subdir it rewrites to http://www.domain.com/subdir. But I have a problem with one subdirectory named "crm" - if I go to http://domain.com/crm it redirects me to http://www.domain.com instead of http://www.domain.com/crm. In this "crm" subdirectory I have another