mod-rewrite

Apache .htaccess to redirect index.html to root, why FollowSymlinks and RewriteBase?

In order to redirect all somefolder/index.html (and also somefolder/index.htm) to somefolder/ I use this simple rewrite rule in Apache .htaccess file: RewriteEngine on RewriteCond %{THE_REQUEST} ^.*\/index\.html?\ HTTP/ RewriteRule ^(.*)index\.html?$ "/$1" [R=301,L] This works well! But at Google groups they suggest to add also: Opt...

phpinfo() mod_rewrite

I'm attempting to perform some url rewriting, and after looking at the phpinfo file, I can't see any mention of this.. My host is FastHosts. Should I be looking for something else in the phpinfo() or should I assume that mod_rewrite is simply disabled? ...

Apache URL Rewrite to domain.com/custom_url_name

Using Apache on a Red Hat server, I'm trying to rewrite the URL of a member's store on our website from: domain.com/store.php?url=12345 to: domain.com/12345 Using these rules, I can get it to work if I always remember to add an ending slash: Options -Indexes Options +FollowSymLinks RewriteEngine on RewriteRule ^store/url/(.*)$ st...

Why is this RewriteRule broken?

Ok folks, I'm at a loss. RewriteCond %{HTTP_HOST} ^domain.nl$ RewriteRule ^(.*)$ poker/$1 [L] Throws me a 500 error. If I remove the redirect and go to /poker/ manually it works. If I use this: RewriteCond %{HTTP_HOST} ^domain.nl$ RewriteRule ^$ poker/ [L] The front page is shown (but the css not, because obviously anything after t...

Problem with .htaccess and RewriteRule

I have url's like games/xbox/2 2 being the page number I need the url rewritten. This is what I'm using: RewriteRule games/(.*?)/$ games/consoles.php?console=$1 RewriteRule games/(.+?)/(.+?)/$ games/consoles.php?console=$1&page=$2 The first rule works fine but the second is returning consoles.php as $1 instead of xbox ...

remove query string from url through mod rewrite.

Hi all, I am very new to mod rewrite so any help would be apprecited. let say i have a site named "www.sitename.com/index.php?p=contact" and i need to remove "index.php?p=" so that it will look like "www.sitename/contact" at its every occurence that means either i should be able to truncate "index.php?p=" or i should be able to replac...

Why won't this mod_rewrite rule work (via .htaccess one specific url to another)

RewriteRule ^/tag/term$ /tag/term-expanded-here [R] ...

How does IIS 7.5's Rewrite Rules thing actually work?

I've imported my mod_rewrite rules... everything works just fine... but seemingly randomly it deletes them all. I've been moving some files around in wwwroot... so, my question is this: When I import rewrite rules, does it create a new file somewhere in wwwroot that I happen to be moving/deleting every time? Thanks for any help you ca...

Apache RewriteRule to simulate directory

Hi StackOverflow ! is there a way to tell Apache to simulate a directory in the URL ? Here is what I'm trying to do... I currently have an URL like http://photo.mydomain.com/pics/17/120417/1.jpg and I would like to be able to reach the same content with an URL like http ://photo.mydomain.com/pics/51/17/120417/1.jpg . Is that possible ...

URL with trailing slash breaks layout - how can I fix this without using base tag?

I am developing a website, and I have set up the following htaccess rules RewriteEngine On #RewriteRule ^([0-9]+)?$ index.php?page=$1 #RewriteRule ^([0-9]+)/([0-9]+)?$ index.php?page=$1&post=$2 RewriteRule ^([A-Za-z0-9-]+)?$ index.php?pagename=$1 RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$ index.php?pagename=$1&post=$2 This ensures...

Adding mod-rewrite to an existing PHP website

I am updating a php app, which currently does not use url rewriting. The aim is to hide file extensions. The general structure of the website is as follows root/ index.php login.php page1.php page2.php page3.php page4.php page5.php page6.php page7.php page8.php subfolder/ index.php validpage.php images/ css/ Th...

Detect if a page have been called via .htaccess RewriteRule in PHP

Hi, I am using .htaccess RewriteRule on a website I'm working on. Here is a sample of my .htaccess RewriteEngine on RewriteRule ^about.htm$ /index.php?load=about&output=html [NC] I would like to know if there is a way in my index.php file to detect if the page have been called via a Rewrite or the user reached it directly. I'm tryin...

Where do I put RewriteRules in Apache2 without using .htaccess files?

I want to configure a mod_rewrite rule without using .htaccess files. When I put rules in .htaccess files they work fine, but I would prefer to leave all of the configuration in my /etc/apache2/sites-available/[site name] config file. When I place the same RewriteRules within the VirtualHost or Directory directives, nothing works. What...

Replace @ with _at_ in URL .htaccess

Hi, I have the following URL: http://testhost.com/offers/311/133/[email protected]/ and I'm wanting to redirect it to this url: http://testhost.com/offers/311/133/test_at_test.com/ Can someone provide me with the Rewrite Conditions and Rule to do this? Thanks in advance! ...

Deny direct access to files or directory using .htaccess

Hi! I'm playing with .htaccess and I was wondering if with just an .htaccess inside the root directory is possible to block all the request from a browser directed on existing files or directories. Let's try this example: RewriteEngine On RewriteBase /~my_user/my_base/ RewriteRule ^list/$ list.php [L] RewriteRule ^element_of_list/([a...

mod_rewrite rule to enforce canonical percent-encoding

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 othe...

Another apache rewrite question...

Hey, In my scenario I redirect "/index/../" to "/index.php?act=..". I was wondering how can I restrict direct access to "/index.php" but still be able to redirect from "/index/../"? P.S. "/../" is anything... it seems you can't use * there. O.o Thanks in advance, The Devil ...

Clean URL's not working, mod_rewrite module installed

I just installed a fresh copy of Drupal 6.19 to get to speed on how to write modules. But for some reason the rewrite module isn't working for Drupal. What I have checked: $ apachectl -M >> it is installed php_info() on current server >> says rewrite is installed also I also double-checked the .htaccess file in my Drupal root folde...

url rewriting directory issue (htaccess)

Good morning. I currently have this little rule in my .htaccess RewriteEngine On RewriteBase / RewriteRule ^brochure/([0-9]+)$ /brochure.php?cat_path=$1 [L] (i'm just using numbers for example here, will be category names later.) This redirects perfectly, but when it does, everything I have in directories now fail (css, js, images, ...

Internal Error when file does not exist

I want get everything up to the "/" and merge with ".php" works fine, but when the file does not exist I get internal error RewriteRule ([^\/]*) $1.php ...