Questions tagged [mod-rewrite]

mod_rewrite is an Apache module that allows for server-side manipulation of requested URLs.

For an introduction and examples of using mod_rewrite, read over the comprehensive article,
"Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask"

2236 questions
2
votes
1 answer

Are these Apache vhost rewrites efficient?

Our ecommerce system has about a 300 - 500 ms TTFB, which I don't think is bad at all, but still isn't as good as a static file. This week I finally experimented with creating my own local cache of product / category pages, and telling our server to…
Mike Willis
  • 203
  • 2
  • 14
2
votes
1 answer

mod_rewrite - RewriteCond if %{HTTP_HOST} is NOT any ServerName/ServerAlias

I want to know if it's possible to make a Rewrite Condition for if the %{HTTP_HOST} is NOT the ServerName or any of the listed ServerAlias. My goal is to redirect any requests made to a domain that is not listed as the ServerName, ServerAlias', or…
Analog
  • 202
2
votes
0 answers

RewriteRule passes request to index.php

I have these two sets of rules in .htaccess: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^ index.php [L] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER}…
camcam
  • 121
2
votes
1 answer

.htaccess: RewriteRule: bad flag delimiters

I added RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} /article/ RewriteRule ! ^article/\d+ redirect.php [L] to .htaccess and got a .htaccess: RewriteRule: bad flag delimiters message. Reviewed the related questions here but they…
chx
  • 1,705
2
votes
1 answer

Using mod_rewrite to rewrite index.html into the cgi-bin folder

Basically, php can only be executed in my host's cgi-bin folder. In my webspace, my index.html file path looks like this: www.example.edu/~username/index.html When a user types that, I would like a mod_rewrite…
2
votes
1 answer

How to get apache to look for files in different subfolders folders?

I am definitely new to mod-rewrite stuff. Note:- here the URL is common, and all the folders and subfolders on same host. The url a user uses to access their page is http://myurl.com/1234/filename.jpg Here the name of the subfolder is an integer is…
prb
  • 21
  • 1
  • 4
1
vote
1 answer

redirect non-www to www AND http to https ONLY for the root path

I'm having a hard time figuring out how to properly configure a mod_rewrite rule for the following conditions: redirect non-www to www AND http to https ONLY for the root path: / ie. example.com disregard anything else such as /test.html ie.…
Ivan
  • 893
1
vote
0 answers

Please help me redirect a URL in mod_rewrite

I'm setting up a new Linux server. I'd like to silently redirect www.domain.com/whatever to www.domain.com/flows/default/whatever unless the flow is explicitly specified, such as www.domain.com/flows/beta/whatever Inside the VirtualHost entry for my…
DaiBu
  • 113
1
vote
1 answer

Apache ModRewrite strip part from request_uri in rewriteCondition

so basically I have a link in my html domain.com/app/css/build/app-23471942834.css however on the server the file actually lives in /fs/current/public/css/build/app-23471942834.css. Is there a way to check if a file exists in a RewriteCondition? The…
1
vote
3 answers

how to rewrite given urls

how can i rewrite www.mysite.com/someURLhere into www.mysite.com/ping.php?url=someURLhere without mistaking local files, and directories as domains. so i dont want www.mysite.com/index.php www.mysite.com/admin/ to rewrite…
gogow
1
vote
2 answers

Rewrite Query String

I have this URL: oldsite.com/profile.php?uid=10 I would like to rewrite it to: newsite.com/utenti/10 How can I do that? I wrote this: RewriteCond %{QUERY_STRING} ^uid=([0-9]+)$ RewriteRule ^profile\.php$ http://www.newsite.com/utenti/$1…
1
vote
1 answer

Dynamic URL to Static URL with mod-rewrite (likely a RewriteRule issue)

I have moved a site from one host to another, and in doing so came across the trap of failing to download my .htaccess file in the process. I am attempting to rebuild said .htaccess based on an earlier (possibly non-working) saved copy, but all I've…
p1agu3
  • 11
1
vote
2 answers

mod_rewrite to redirect to specific WP page

The goal is to redirect all requests coming to Wordpress from IE 6 and 7, to a specific Wordpress page using mod_rewrite. My confusion comes from multiple conditions that are needed for the rewrite not entering an endless loop once on the specific…
djdy
  • 583
1
vote
1 answer

Need to redirect all non www to www and all https to subdomain

Having trouble writing this compound rewrite containing the following rules: Requirements: Redirect all http://example.com -> http://www.example.com Redirect all https://* -> http://wwws.* Enforce all /checkout/* page to use https: E.G.…
chrisjlee
  • 1,015
1
vote
2 answers

Insert root level directory for all image requests

I am working on a site migration and I need to set up some redirects for image files. Certain image path requests will come in to root-level subdirectories and I need to put /new_directory/ as the first directory for all of them, like so: Old site…
user26664
  • 287
  • 1
  • 2
  • 7
1
2 3 4