mod-rewrite

mod_rewrite - How to remove subdirectories from the url? (and fix other problems caused by doing so)

So I've been trying to shorten my urls. The images I want to display are located at http://domain.com/images/pic.jpg I would ideally like to be able to navigate to them by going to http://domain.com/pic. I have got that bit working, with a few issues (commented on below). But now I can't navigate to http://domain.com/index.php because ...

Regular expression to allow for number values between 1-3 digits?

In my .htaccess file I have the following rule: RewriteRule ^gallery/[0-9][0-9][0-9]/$ index.php?gallery_id=$1 It allows for any number that is three digits in length. I do not know how to allow for less than three digits as well (or more than three for that matter). I am still new to regex. Thank-you! ...

How to remove directory from url using mod_rewrite?

How can i turn http://domain.com/foo/bar.jpg into http://domain.com/bar while keeping the rest of the website working? ...

HTAccess Rewrite Needed

I need to rewrite any url on my domain that starts with /club/anyPage to /page/club/anyPage. For this, I believe I can use the following command: RewriteRule ^club/([^/]*)$ /page/club/$1 [NC] Also, if the physical page does not exist I want it conditionally rewritten like so: /club/$1 to /page/club/club.php?title=$1 So in this ...

modified .htaccess file doesn't block bad user agents with RewriteCond

Hi. I found this modified .htaccess settings for extra security, but it doesn't seem to work. Here it is : # Apache configuration file # httpd.apache.org/docs/2.2/mod/quickreference.html # Techniques in here adapted from all over, # including Kroc Camen: camendesign.com/.htaccess ServerSignature Off # you probably want www.exampl...

mod rewrite rules help please

hello , i made a script .. and i want to make it's all urls to be seo friendly .. my current php urls is : index.php?lang=ar&option=a&option_m=band variable option&option_m are optional so i want convert this url to /ar/a/b or /ar/a or /ar and i want ask about if the page have form with GET Action ,, how to accept the query ...

Dynamic .htaccess

I am creating a modular CMS using the codeigniter framework, the main asset directory is: /public/assets/[admin|public]/[css|images|js] my current htaccess routes everything except requests starting with 'public' to the index.php file. The new module system allows each module to have its own assets which would be located at applica...

Apache RewriteRule and Skipping Logic

I've pretty much hit a wall here. As far as I can tell, this should work, but it doesn't. I have a local development address with a wildcard subdomain of *.localhost, and friendly URLs of /[0-9]/somestring. What I am trying to do is have username.localhost/1/page to localhost?pageId=1&username=username. The complication comes in tryi...

Apache: %25 in url (400 Bad Request)

I have a url containing the following: /somepath/morestuff/ohno%25foobar For some reason apache is reporting a 400 bad request (it has something to do with the %25). I am using mod_rewrite to rewrite the path to point to my codeigniter instance but it's not even getting to codeigniter, it's just the default apache error. Any ideas? ...

How do I redirect all but one url to a script

I'm trying to get www.example.com and www.example.com/index.html to go to index.html, but I want all other urls e.g. www.example.com/this/is/another/link to still show www.example.com/this/is/another/link but be processed by a generic script. I've tried RewriteEngine on RewriteCond %{REQUEST_URI} !^index\.html$ RewriteCond %{REQUEST_UR...

Apache Rewrite SSL Problem

My application server has two ways to call it. One via the WEB and one via SOAP XML calls. As you can see in my apache config file I have two PORT 80 entries, 1 for the website and one for the soap calls. Both with specific rewrite rules to lead the traffic in the right direction.. now im trying to get SSL in place. I made the first web...

Is there a way to do some sort of regex loop in .htaccess

hi at the minute I have a list of rules in my .htaccess file but if I need to add a new page i then need to edit this file again and add yet another rulles. HEre is a few RewriteRule ^admin/(.*).html$ index.php?x=admin&y=$1 RewriteRule ^admin/project/(.*).html$ index.php?x=work&p=project&$1 RewriteRule ^work/(.*).html$ index.php?x=work&...

Mod_rewrite syntax with query strings

Embarrassing as this may be, I've hit a wall with mod_rewrite trying to come up with what seems to be a simple rule. I'd like to accomplish the following mapping: /cat/subcat which may have a "?PageId=123" afterwards should become /cat.php?cid=148 or (/cat.php?cid=148&PageId=123) So for example, the following 2 mappings would occur:...

rewrite url using htaccess

How can I change url in this way using htaccess: http://example.com/page.php?go=something.php should be redirected to: http://example.com/something If the get parameter name is different than 'go' leave as it is... ...

.htaccess subdomain to folder

Hey all, I've recently made some minor changes to my website's folder structure, and now one of my rewriterules seems broken. in the past I had a /mydomain.com/ folder in public_html in which a wiki was set up. In the same folder were some folders that I used for subdomain access, like members and files. The old setup: #www to main w...

Zend and modrewrite not working together properly

I'm setting up a Zend application, and went through the basic steps of setting up modrewrite on my development station, and writing an .htaccess file (shown below). Now, when I go to the root of my project, Zend works properly, calling the controller and displaying the appropriate page. However, when I call any controller, I would expec...

htaccess redirect for existence of a specific URL variable

Hello all, I've been reading hard for a good few hours and still can't find what I need! Hopefully someone here can help. What I want to achieve is to redirect a specific URL with a specific variable to another page, but not when there are other URL variables present. eg. index.php?option=com_user - this needs to be redirected to i...

Trying to use .htaccess rules to redirect to load FR content w/ a FR domain and EN content w/ an EN Domain

I'm using MediaWiki with mulitlingual subpages. When I go to "english.com/Page_title" I want to load just that (which is the default) When I go to "french.com/Page_title" I want to load the /fr subpage, which is "french.com/Page_title/fr" and here's my current rules: RewriteBase / RewriteRule ^[^:]*\.(php|src|jpg|jpeg|png|gif|css|js...

Quick string replace mod_rewrite question

all i want do is change my querystring from this result/?q=Southview+Guesthouse to this: result/?q=Southview-Guesthouse. I've done similar stuff with PHP but never mod_rewrite, has anyone got any ideas? Thanks. ...

RewriteCond not stopping at end.. /example will work... but example/anotherlink doesnt

Hi.. this might be a no brainer to some, but I am trying to specify some RewriteCond in an .htaccess file and I am failing badly. Heres what I have : RewriteCond %{REQUEST_FILENAME} employee [NC] RewriteRule ^(.*)$ /resources/employee [L,R=301] will redirect fine... but if I include any other rules that include 'employee' like th...