0

Ive read a few tutorials to try and get this mod_rewrite to work but have no luck. I have checked my phpinfo and everything should work.

I am trying to change this url: http://domain.com/viewAlbum.php?aid=2 (any number)

to this url: http://domain.com/album/2/

Here is my .htaccess file and I dont know if I have this set up correct.

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^album/([0-9]+)/$ viewAlbum.php?aid=$1 [NC,L] 
RewriteRule ^(\w+)$ http://domain.com/viewAlbum.php?aid=$1

I copied the last line of code from another thread on here.

Any suggestions would be awesome!
Thanks,
Brian

5
Contributors
14
Replies
16
Views
6 Years
Discussion Span
Last Post by bjeffries
0

I am pretty new with this myself but dont you need to type in;

<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^album/([0-9]+)/$ viewAlbum.php?aid=$1 [NC,L]
RewriteRule ^(\w+)$ http://domain.com/viewAlbum.php?aid=$1
</IfModule>

?

0

ok so I added <IfModule mod_rewrite.c> and </IfModule> to my .htaccess file and to be honest I dont know if it worked. I am not seeing any changes so I am still stumped on this one.

0

I have got to be doing something wrong or I need to add something else to my .htaccess file? there is not way all of this is not doing a thing.

Here is what I have in my file again:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^album/(.*)(/?)$ /viewAlbum.php?aid=$1
RewriteRule ^(\w+)$ http://domain.com/viewAlbum.php?aid=$1
</IfModule>
0

I deleted line 6 and I still get no change. Maybe my server doesn't allow me to upload my own .htaccess file? Is there something I can put in the file to see if there is any change?

0

Remove the <IfModule> lines.

If you try:

RewriteRule .* error.html

Everything should be redirected to error.html

0

I got a firefox error:
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

I get that error when I add RewriteRule .* error.html but when I took it out the page loaded fine, but still no change with the original problem. I also took out the <IfModule> lines.

0

Either way, with or without the [L] flag I still get redirected to the firefox error page.

I removed the RewriteRule .* error.html [L] line of code and put the [L] flag after:

RewriteRule ^album/(.*)(/?)$ /viewAlbum.php?aid=$1 [L]

And I still got nothing.

Could there be another flag I need to use with the [L] flag to make it work or something?

Edited by bjeffries: n/a

0

Ok so I have been searching google all day long trying to figure out how to get this mod_rewrite issue handled and nothing. I have been trying to get this to work through two hosting companies: 1and1 and visox.

I have tried to use code for both sites with no luck. here is my .htaccess file I am using on the 1and1 site,(most of the code here was pulled from google with people saying they have similar issues)

#Access Handler

AddType x-mapp-php5 .php

#1and1 server fix

Options -MultiViews

#Rewrite Rules

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php [L,QSA]
RewriteRule ^c/([^/.]+)/?$ index.php?page=$1 [L]

Then, my other one is much simpler but also doesn't work on either server:(also pulled from google with related issues.)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php [L,QSA]
RewriteRule ^(\w+)$ http://domain.com/viewAlbum.php?aid=$1 [L]
</IfModule>

Any suggestions?

Edited by bjeffries: had the wrong line of code in there.

0

Where are you saving the .htaccess file? I was having trouble with mod_rewrite before and couldn't figure it out but it turned out that I had saved the file in the wrong place. I had saved it in the same folder as the server configuration files but it's supposed to be in the web root folder (with your index file etc).

0

Yeah, I do save them in the root folder. I am going to try and contact both web hosts and see what the deal is, I doubt they will do anything, but I am gonna try.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.