Need help with setting up the url rewrite

New to mod_rewrite? This is a good place to start.

directory not allowed

Postby revo » Sat Jun 20, 2009 8:40 am

I put that in which you said into my .htaccess file, then previewed my index.php page and it says internal server 500 and my apache error log says:

[Sat Jun 20 11:32:15 2009] [alert] [client 127.0.0.1] C:/wamp/www/mylocalsite/.htaccess: <Directory not allowed here

I made sure the .htaccess in my my main directory in c:/wamp/www/mylocalsite/

I also double checked again my httpd.conf file to make sure # is removed from line
LoadModule rewrite_module modules/mod_rewrite.so

and it was.
Am I overlooking something else?
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Sat Jun 20, 2009 8:51 am

You can't use <Directory> in a .htaccess file. <Directory> is used in your httpd.conf file.

You want
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^stores/deals/([^/]+)/?$ /deal.php?name=$1 [QSA,L]

only.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

url the same

Postby revo » Tue Jun 23, 2009 10:27 pm

Hi, I found my mistake. I did not put this into the httpd.conf file:

<Directory /wamp/www/mylocalsite/>
Options +FollowSymLinks
AllowOverride All

Options +FollowSymLinks

RewriteEngine On

RewriteRule ^stores/deals/([^/]+)/?$ /deal.php?name=$1 [QSA,L]
</Directory>
-----------------------------------------------------
Now that my page shows up, I'm still not able to see the nice url showing, I still get this:

http//localhost/mylocalsite/stores.php?name=Sears

*I took the colons out after http here so it doesn't make it a link.

The Error log says this:

[Wed Jun 24 01:05:31 2009] [error] [client 127.0.0.1] Directory index forbidden by Options directive: C:/wamp/www/mylocalsite/logo/, referer: http//localhost/mylocalsite/stores.php?name=Sears
[Wed Jun 24 01:05:31 2009] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/customerrors, referer: http//localhost/mylocalsite/stores.php?name=Sears
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Wed Jun 24, 2009 8:29 am

Try
Code: Select all
<Directory /wamp/www/mylocalsite/>
  Options +FollowSymLinks +Indexes
  AllowOverride All

  RewriteEngine On

  RewriteRule ^stores/deals/([^/]+)/?$ ./deal.php?name=$1 [QSA,L]
</Directory>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

no result in url yet

Postby revo » Wed Jun 24, 2009 4:13 pm

The new error after I put in what you said into my httpd.conf.


[Wed Jun 24 19:08:08 2009] [error] [client 127.0.0.1] Directory index forbidden by Options directive: C:/wamp/www/mylocalsite/logo/, referer: http//localhost/mylocalsite/stores.php?name=Sears
[Wed Jun 24 19:08:08 2009] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/customerrors, referer: http//localhost/mylocalsite/stores.php?name=Sears
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Thu Jun 25, 2009 1:12 pm

You get that error when you go to /mylocalsite/stores/deals/Sears/? What do you see in your browser?

I think i will need to see your whole httpd.conf file. You can post it here or email it to uv7t813g AT googlemail.com.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

404 error

Postby revo » Sat Jun 27, 2009 6:58 am

The requested URL /stores.php was not found on this server

when I type /mylocalsite/stores/deals/Sears/ in the browser. I have also emailed you my copy of httpd.conf file.


Thank you for the help.
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Sun Jun 28, 2009 1:05 pm

The requested URL /stores.php was not found on this server

Is /mylocalsite/stores.php the correct location?

I have sent you an edited version of your httpd.conf file.

Out of interest, why are you putting the mod_rewrite in your httpd.conf file?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby revo » Mon Jun 29, 2009 8:32 pm

I am putting it in httpd.conf because I was trying to follow your directions for setting up a local server mod rewrite in your other forum, maybe I understood it differently, I'll read again.

Yes the path is this:

http//localhost/mylocalsite/index.php

I checked and didn't see an email, please resend, and if possible I would rather not mess with the httpd.conf file, but I am a little confused now.
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Tue Jun 30, 2009 2:54 pm

I have emailed you a new httpd.conf file.

Once you have it, try the following in /mylocalsite/.htaccess
Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteRule ^merch/merchant/([^/]+)/?$ merch.php?merchant=$1 [QSA,L]

Then go to /mylocalsite/merch/merchant/Sears. You should see the same as if you had visited /mylocalsite/merch.php?merchant=Sears.

email wrote:It doesn't change the way the url displays, it just shows the .../merch.php?merchant=Sears

Mod_rewrite doesn't change the links that are outputted by the script, it works on the incoming requests only. You must edit the script to output the new URLs.
Last edited by richardk on Wed Jul 01, 2009 8:39 am, edited 1 time in total.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

PreviousNext

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 29 guests

cron