mod-rewrite

Avoiding sub-directory request rewrites with Apache mod_rewrite

I want to a rewrite rule such that if a user goes to the URL example.org/stuff/junk.jpg the rule will process and end up at re-writer.php but if the user goes to example.org/stuff/hackingisawesome/junk.jpg the rule will not be triggered and they will get a standard 404 (or a page, if one should exist). I can't tell, based on the environ...

How to tell that a folder has been deleted permanently

Hello, I have deleted a folder called forums from my website from 3 months. but in my Google Webmaster Tools it keeps saying that e.g. /forums/member.php?u=1092 is missing (404). is there any way to stop these messages and tell google that i am not going to re-upload it? is this going to affect on my SEO ranking? I tried this code, bu...

Having trouble searching for a '.' using htaccess.

I'm setting up a website that (ideally) would allow users to access other users' homepages with a url in the format "www.mysite.com/Page/ThisLanham" where 'ThisLanham' is the username. The username begins with a letter and can consists of any alphanumeric character along with an underscore, hyphen, or period. So far, the redirection has...

htaccess and sessions/cookies

Im having a problem with a htaccess rewrite rule on a site im working on. Main Dir's htaccess: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^website.com [NC] RewriteRule ^(.*)$ http://www.website.com/$1 [R=301,L] This site forces the user to www.website.com, even if they enter the address sans the www. Now i have a wordpr...

Should we check slugs passed in URLS or just use the ID?

For example, if you access this url :http://stackoverflow.com/questions/286004/hidden-features-of-modrewrite and this one http://stackoverflow.com/questions/286004/hidden-features-of-modrewrite-PUT_ANYTHING_YOU_WANT_HERE. It goes right to the same page, and it seems Stackoverflow doesn't check for a valid slug (as wordpress calls it). ...

mod_rewrite causes loss of stylesheet

Hi there! I'm using mod_rewrite to clean up some of my URL's (duh) and I got it working. Sorta. It redirects to the correct page, but the stylesheet doesn't show up. Here's my code in .htaccess: RewriteEngine on RewriteRule ^blog/([^/\.]+)/?$ post.php?page=$1 [L] So what's going on? This is my first time working with mod_rewrite, by t...

How many files do search engines index per directory

I'm using Apache Mod RewriteRule to deal with dynamic URLs. And trying to figure out the best URL structure to go with. Here are the options I am thinking about: They will all rewrite to: mydomain.com/myprogram.php?username=$1&cat=$2&item=$3 Option 1: mydomain.com/username-category-item-5.html Option 2: mydomain.com/username/categor...

How can I rewrite urls into pretty urls using mod_rewrite and php?

Hello, First off I wanna apologize for my ignorance but mod_rewrite and regex seems just a bit complicated for me and I need this done fairly quickly. Basically what I'm trying to accomplish is the followings: Get rid of the .php extensions and get rid of the index.php - Basically when a user enters http://www.example.com/index.html ...

How to insert an "index.php" into every url using .htaccess?

Example: My Site gets called like that: www.mysite.com/controller/method/parameter1/parameter2 Now, .htaccess needs to rewrite this URL into: www.mysite.com/index.php/controller/method/parameter1/parameter2 But the problem is: In case of an img, css or js directory, no redirection should happen. How can I achieve this? What must I...

Why does this RewriteRule cause an Internal Server Error?

I call my site this way locally: http://localhost:80/mysite/de/layer1/layer2/module In .htaccess I have: RewriteEngine on RewriteRule !^((css|js|images)/.*)$ index.php%{REQUEST_URI} [L, NE] I try to rewrite that into: http://localhost:80/mysite/index.php/de/layer1/layer2/module Any idea what's wrong there? EDIT: If I write onl...

Any easy, noncluttering way to set up "mydomain.com/username" using PHP?

Simply put, when a user wants people to be able to go to their profile, we want them to be able to just say go to mydomain.com/username. The real user page would be at something like mydomain.com/users/page.php?id=1325 which doesn't really help users. The problem: I've been doing PHP for some time, and have never had the need to do thi...

Easy mod_rewrite - So I'll never have to think about it again

Not sure how you'll take this question but... Whenever I try to make my URLs look pretty I always end up messing around for too long and it's simply not worth the trouble. But the end effect is good if it were a simple task. So what I want to do is create a method which in the end would achive something like... index.php?do=user&usern...

.htaccess rewrite and subdomains

I have a subdomain setup as onlinedev.domain.com I need to use htaccess to rewrite to domain.com/online_content, while still showing onlinedev.domain.com in the address bar (SSL is for onlinedev.domain.com). this is what I currently have that is very close: php_flag display_errors off RewriteEngine On RewriteCond %{HTTP_HOST} !^$ Rew...

Apache Rewrite and variable

Hi, I would like to rewrite: http://url.com/app%5Fname/action.do to http://url.com/context/action.do?value=1 My question is how to add the variable 'value' to the url for each rewrited URL (it's a hard coded value) ? #RewriteRule ^/app_name(.*) /context$1 Thanks! ...

How can i set optional parameter in the Mod Rewrite-Syntax?

I'm german and i'm sorry about my damn sucking englisch. RewriteRule ^admin/(.*)$ index.php?admin=$1 here is an example. so the result i want is for example the id within, but as an optional parameter: RewriteRule ^admin/(.*)/id-(.*)$ index.php?admin=$1&id=$2 Here the id don't must set thats what i want :) The Link example (i want...

URL Rewrite Apache locating files

I have a url rewrite that looks like this: RewriteEngine On RewriteRule ^cancun/tours/$ location-tours-listings.php?locationName=Cancun RewriteRule ^cancun/tours$ location-tours-listings.php?locationName=Cancun Problem is that now the page can't find the relative URL's, such as CSS, images, etc... Is there a way to fix this with a co...

Help with .htaccess file's rewrite rule

I apologize in advance if I missed someone cover this already; I tried to see if someone had my own .htaccess dilemma: I currently have the following website: www.example.com I want to set it up like the following: somewebsite.example.com And have the subdomain "somewebsite" point to a subfolder on my root. If that subdomain is not av...

.htaccess - route to selected desination but change browser url

Problem: I'd like to accept the original request. Say its, /IWantToGoHere/index.php but I want to return to the browser, /GoHere/index.php To be clear: I actually want to send the original request location down to the script requested, however, I want to return the user a browser URL to another destination. Code: RewriteEngine on Rewr...

Mod Rewrite - How to point main site to subfolder

Hello I've domain using wildcard dns but I want my main site example.com will grab content from folder /home/ by example. If user type http://www.example.com/ or http://example.com/ site will read file from subfolder /public_html/home/ If http://subdomain.example.com/ will reading content from /public_html/. Let me know how to that ...

return 404 error on existing directory

Ok so i have a directory in my root folder called /pages in which i keep all my pages that i include thru index.php What I wonder is would could i somehow return a 404 error if someone requests it? i dont like snoopy people... ...