user622905
user622905

Reputation:

url rewrite not working in apache?

hi im working with PHP application. Now i wanted to implement the URL rewrite concept for SEO friendly My Current URL is domain.com?category-view.php?manufacturer=Apple

i wanted the above URL as

domain.com/category-view/manufacturer/apple (or)

domain.com/category-view/apple

I have created the .htaccess file and put this code for rewrite

RewriteEngine On
RewriteRule ^([A-Za-z0-9_-]{4,60})$ category-view.php?manufacturer=$1 

But its not working up. help me to fix this

Upvotes: 1

Views: 11478

Answers (5)

Ishtiyaq Husain
Ishtiyaq Husain

Reputation: 424

Add this line before "RewriteEngine On"

Options +FollowSymLinks -MultiViews

It worked for me.

Upvotes: 1

Mohammad Efazati
Mohammad Efazati

Reputation: 4910

load mod_rewrite

  1. Before you begin this, please make sure you make a backup copy of the original file in case you make a mistake, this way you can always go back to the original configuration - always backup before you begin doing something like this.)
  2. Find the httpd.conf file (usually you will find it in a folder called conf, config or something along those lines. In Fedora you can find it at /etc/httpd/ directory.)
  3. Inside the httpd.conf file find and uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound '#' sign from in front of the line - the # sign is for comments, by removing the # sign, you are uncommenting the line)
  4. Also find the line ClearModuleList is uncommented then find and make sure that the line AddModule mod_rewrite.c is not commented out. (I didnt find these in Fedora, yet my mod_rewrite works great)
  5. After you have made the changes and saved them, restart your httpd (apache) server for the changes to take affect. The easiest way to do this is to go to the shell command and type: /etc/init.d/httpd restart (this works for Fedora, might be different for other distributions!)
  6. Done

from http://www.wallpaperama.com/disp-post10.html

see also http://httpd.apache.org/docs/current/mod/mod_rewrite.html

Upvotes: 1

darklion
darklion

Reputation: 1055

According to http://httpd.apache.org/docs/current/mod/mod_rewrite.html when you use a RewriteRule in a .htaccess file you need to specify the base url using RewriteBase or it substitutes the filesystem path instead. So, try adding this to your .htasccess file:

RewriteBase ?

Upvotes: 1

Aleksi Yrttiaho
Aleksi Yrttiaho

Reputation: 8446

This works for me

RewriteEngine On
RewriteRule ^category-view/([A-Za-z0-9_\-]{4,60})$ category-view.php?manufacturer=$1 

Upvotes: 1

Sandwich
Sandwich

Reputation: 2289

Have you checked to see that mod_rewrite is enabled on your installation? You can quickly check by putting <?php phpinfo() ?> in your file. Do a find for 'mod_rewrite'.

Upvotes: 0

Related Questions