Jump to content

mod_rewrite


talreja_sapna

Recommended Posts

it might be better to explain what you're trying to achieve - simply uncommenting something generally just makes things available for you to use rather than changing things automatically.

mod_rewrite is about rewriting URL's. if you've seen wikipedia's URLS, or URL's without lists of parameters after the filename, then mod_rewrite is possibly at work.

as it's generally done on a site by site basis, the best way is to create a text file in your webroot called .htaccess (notice the fullstop before the name).

as for the rest - you need to decide what you want to achieve with the URL, get a grasp of regular expressions and go from there. Here's the main doc for it: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

assuming you've already got that far, and it's not doing anything, do you have a: RewriteEngine On in your htaccess file?

hope that helps
Cheers
Mark
Link to comment
Share on other sites

Whats your rewrite rules. Post your rewrite rulese here.

You need to setup some rewrite rules in a htaccess file in order for http://domainname/john to work.

Fo example. You have a file called profile.php and you use a url parameter called user, which profile.php uses to grab the details of that user. Instead having to type http://domainname/profile.php?user=user_here
You want to use http://domainname/user_here

In order to do that a rewrite rule needs to be setup for modRewrite to use. So your rewrite rule will be something like this:
[code]# Tell Apache you want to use mod_rewrite
RewriteEngine On

# Setup the rewrite rul
RewriteRule ^([a-zA-z]+)$ profile.php?user=$1[/code]

You cannot just uncomment the mod_rewrite module and expect it to work just like that.
Link to comment
Share on other sites

hi
thanks
actually i am working with the mod_rewrite for the first time
so for checking whether its working or not
i had written the following in .htaccess

RewriteEngine On
RewriteRule ^/alice\.html$ bob\.html

if user try to access alice.html bob.html should be called but its not working
thanks
sapna
Link to comment
Share on other sites

No. You cannot enable the mod_rewrite in a htaccess file. All Apache modules have to be enabled via the server configuration (httpd.conf) file.

Ask your host whether they can enable the mod_rewrite module. If they will not enable the module then you'll either have to find a new host, or upgrade your hosting plan to one where you can control the Apache configuration yourself (most probably  a dedicated server plan) or dont use mod_rewrite.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.