Jump to content

rewrite base help


phpnewby1918

Recommended Posts

Hi,

 

I've been looking into the apache mod_rewrite for quite a few days now, but i can't seem to get it to work. I have read around a lot tyring to understand it more. I believe my server does allow the rewrite as i did:

 

RewriteRule ^somepage.html somepage.php

 

And that worked fine. I am trying to rewrite URL so its prettier for this page.

 

I wanted to start of with a basic (if there is a basic one)  ;D

 

I have a page called 'about.php'

where i pass a get variable to recall a more in depth article from the introductory text on about.php.

 

for example

 

about.php?x=jonathon

 

goes into more depth about 'jonathon'

 

I would as one could imagine like to rewrite this URL so that it looks like:

 

about/jonathon/

 

So i have tried this .htaccess rule:

 

<IfModule mod_rewrite.c>

  Options +FollowSymLinks

  RewriteEngine On

  RewriteRule ^about/([A-Za-z\+]+)/ about.php?x=$1 [NC]

</IfModule>

 

But nothing changes in my url. I have had quite a lot of attempts at this, unfortuantely to no avail and read many articles and guides  :wtf:

 

Could someone show me the error of my ways please

 

Any help very appreciated

 

Jonathon

 

 

 

Link to comment
Share on other sites

Hi thanks for your reply.

 

I went to this option, what do you think of it?

 

I did try yours, but it didnt seem to work - sadly.

 

mine was this:

 

Options +FollowSymLinks 

RewriteEngine on

RewriteCond %{SCRIPT_FILENAME} !-d 

RewriteCond %{SCRIPT_FILENAME} !-f 

RewriteRule ^about/?$ about.php

RewriteRule ^about/([A-Za-z\+\-]+)/?$ ./about.php?x=$1 

 

You clearly know more about Apache than me, so be interested on your take of the code. I'm a newbie to Apache mod_rewrite.

 

Also, can you think of a way to stop my css failing.

 

It works fine on mysite.com/about

 

but when i clcik my link that goes to mysite.com/about/jonathon

 

the CSS fails. I'm running the content for the 'jonathon' variable on the same page as about and i guess the extra '/' after about is making the page think it that the CSS folder (which is in my root)  is in the same 'directory' as about. But obviously the fake folder of /about/ isnt anywhere else as its still in the root.

 

I know i could use absolute paths for CSS if all else fails. But i'd just prefer to use relative ones IF possible??

 

Appreciate anyones help

 

Jonathon

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.