.htaccess

RewriteRule to redirect tp a page for a second subfolder variable

FTR, I'm pretty abysmal at rewrite rules. We've got a number of users who each have their own projects. Right now we've got the RewriteRules set up so that when someone just types mysite.com/username it goes to the user's profile at, f.e., mysite.com/work/user_name.php?u=000 But what we really need is, when someone types in mysite.co...

Rewriting URL with selected query string parameters in .htaccess

I recently changed my CMS, and want to rewrite some of my URLs to match the new URL/query string parameter format. The old URL was: http://www.mysite.com/search.cgi?tag=foo&blog_id=bar&other=baz The new URL should be: http://www.mysite.com/?s=foo In other words, there were several query string parameters in the old format,...

Need help with rewrite rules with sub folders please.

We've created a jkMount in Tomcat named "shopping" and then applied this rewrite rules on Apache: # when Query String RewriteCond %{QUERY_STRING} !^$ RewriteRule ^pt/?([a-zA-Z0-9\./_-]+)? $1?idLang=1&%{QUERY_STRING} [NC,PT,L] RewriteRule ^en/?([a-zA-Z0-9\./_-]+)? $1?idLang=2&%{QUERY_STRING} [NC,PT,L] RewriteRule ^es/?([a-zA-Z0-9...

Apache Rewrite is not working with subfolders

Hey Guys, As the apache docs state: "The configuration directives found in a .htaccess file are applied to the directory in which the .htaccess file is found, and to all subdirectories thereof." Which means that a rewrite in the root .htaccess affects all other folders in the website correct? That is what I've always thought, and have ...

correct format of URL rewrite in php

Hello All, i'm asking about htaccess url rewrite ( mod_rewrite ) actually i want to change below URL http://localhost/project/cms/edit_item.php?id=MYc= ( actually this is base 64 encoded) to http://localhost/project/cms/edit_item.php/id/MYc= i do it like this on .htaccess file RewriteEngine on RewriteRule ^([\-_0-9A-...

Rewrite vs already rewritten (remove subfolder from URL)

So right now, this is what I've got: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} cpattyn\.uni\.cc RewriteCond %{REQUEST_URI} !^/ffs/public/ [NC] RewriteRule ^(.*)$ ffs/public/$1 [L] RewriteCond %{HTTP_HOST} ztz\.110mb\.com RewriteRule ^ffs/public/(.*)$ http://cpattyn.uni.cc/$1 [R=301,L] So this does the following: -cpatt...

htaccess url rewriting

Is there an easy way to 301 redirect http://www.site-name.com/yellow-cars to http://www.site-name.com/shop/catalog/all/Yellow_Cars I'm not sure if the last segment in the URL can be created in the .htaccess file? ...

RewriteRule variables blank

I have a couple of rewrite rules in htaccess. They work on one server but not another. My script is as follows (I've commented out how the urls look): RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/images/ #example.com/regions/fife/ RewriteRule ^regions/([A-Za-z0-9\-\+\']+)/?$ /regions.php?region=$1 [L] #example.com/regi...

If No File, Rewrite URL

I have two .htaccess files that I need to combine into one. The first one does a simple file extension remover. The second one rewrites all requests to go to a third party app, keeping our URL. What I need is to have the rules be smart enough to not look at the second server if the file exists on the first. Rule1 : RewriteEngine on ...

Dynamic pages and clean URL conflicts.

I did some looking around at how other sites might handle this and didn't really see anything that jumped out at me. I'm working on a project where you can create pages that get linked to from every other page. Here is where the issue is coming up for me. I'm not sure how I should go about linking to these pages. I've only really though...

mod_rewrite with an unknown number of variables

I'm trying to use mod_rewrite to handle an unknown number of variables. An example URL would be: example.com/var1-var2-var3/title I have this so far: RewriteRule ^([^/.]+)-([^/]*)(.*)$ $3?version[]=$1&version[]=$2 [QSA,N] RewriteRule ^([^/.]+)/?$ ?title=$1 [QSA,N] RewriteRule ^/?$ /index.php [QSA,L] This returns: Array ( [title] ...

htaccess Redirect to same file, but display different URL without having to change internal links?

I currently have links on my website in the form of:- http://example.com/products.php?cat=X I want that once taken to the destination of the link, the url displays something like:- http://example.com/new. The file on my server is the same file, but only the url should appear neater without me having to change any of the links. I tri...

RewriteRule RegEx - Add another variation of subdirectory level mapping to URL

I am passing one of the following URLs to a site an want it to split into the proper parameters. http://example.com/storevar?search_term http://example.com/storevar/?search_term http://example.com/storevar http://example.com/storevar/ http://example.com/storevar/search_term http://example.com/storevar/search_term/ ...

htaccess mod_rewrite:- products.php?cat=1 to /myfolder1/myproduct1/

I've got a url type:- http://www.example.com/products.php?cat=1 which I am able to rewrite to:- http://www.example.com/myproduct1 using the following .htaccess rule:- RewriteRule ^myproduct1$ products.php?cat=1. What rule would I need to enter if I wanted to rewrite to:- http://www.example.com/myfolder1/myproduct1/? ...

Apache RewriteCond from result of php request

I would like to add a rewrite Condition in my htaccess that would be true if calling a php file returns "true" or false otherwise. I' am using the -U switch in my RewriteCond to run a subrequest and if the condition is not satisfied, the PHP script returns a 404 error, which triggers the rewriteCond. My goal is to run a URL shortening s...

htaccess - internal redirects problem - cpu load

Hi, I have the following in my .htaccess file: php_flag magic_quotes_gpc off Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-s RewriteRule ^admin(.*)$ admin/index.php [L] RewriteCond %{REQUEST_FILENAME} !-s RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L,QSA] The idea is...

500 error for clean url mod re-write

Thanks to everyone who has helped me with my clean URL quest. I'm almost there but want to lick this last thing. .htaccess RewriteEngine on #REMOVE THIS LINE ON SITE LAUNCH! RewriteBase /~accountName/ #Hide .php extensions for cleaner URLS RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ ...

Using same .htaccess in different environments

From development to testing to production our website resides in three different environments http: //localhost/version/ http: //www.production.com/test/ http: //www.production.com/ (see examples of URLs in the following .htaccess snippet) Options +FollowSymlinks RewriteEngine on RewriteRule ^brand/(.+) /products.php?brand=$1 [R,NC]...

How Do I Cache Just the Homepage with Apache .htaccess?

Below is an example on how to cache all files on the server ending in html or htm for 2 hours (7200 seconds). So how would I go about doing this only for the homepage of the website, but not any other URL? <FilesMatch "\.(html|htm)$"> Header set Cache-Control "max-age=7200, must-revalidate" </FilesMatch> I tried a Directory and a Loca...

.htaccess Rewrite URL images not showing - directory confusion.

Okay so I'm rewriting a URL domain.com/id/text to domain.com/page.php?id=id using mod_rewrite / htaccess Options +FollowSymlinks RewriteEngine on RewriteCond %{http_host} ^webresauce.com [nc] RewriteRule ^(.*)$ http://www.webresauce.com/$1 [r=301,nc] # Rewite URL Starts here RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FIL...