Jump to content

Recommended Posts

I'm trying to rename my urls in the address bar but for some reason it isn't taking any effect

 

4 pages i have tried on so far, the url in the web browser remains the same, am i missing something or is there something i need too change on my actual .php's? At the moment i haven't touched them and only uploaded the htaccess to my root directory.

 

Options +FollowSymLinks
RewriteEngine  on

RewriteRule ^/members/products/garden\.php$ category=garden [L]
RewriteRule ^/members/products/home\.php$ category=home [L]
RewriteRule ^/members/products/pets\.php$ category=pets [L]
RewriteRule ^/members/products/gifts\.php$ category=gifts [L]

Link to comment
https://forums.phpfreaks.com/topic/242391-htaccess-url-rewrite/
Share on other sites

1. The URL that RewriteRule works on doesn't normally start with a slash. But sometimes it does. I still don't know when that is.

2. I doubt you want to redirect to the address "/category=garden".

 

Unless you want to restrict the rewriting to just those four categories,

RewriteRule ^/?members/products/(\w+)\.php$ index.php?category=$1 [L]

will handle all of them at once.

 

The URL in your browser will not change. If you want it to then add an [R] flag to the Rule.

Sorry i poorly explained what i'm trying to achieve. What im trying to do is hide the file structure of my site so at the moment for example my 'garden' category is at www.website.com/members/products/garden.php.

 

I just want that to appear as www.website.com/category=garden. It doesn't have to be exactly that, but that's easier for me to identify

Thanks for the reply. It still appears to not work, the address isn't changing, unless im doing something wrong.

 

Does the .htaccess file have to go in the same category? So lets say for the 'garden' link, do i have to put a .htaccess in the members/products/ folder, and same for all other folders, or is it just one file in the root directory?

 

Do i need to alter my .php in any way?

 

Appreciate your patience.

OK, i fixed it by changing my link in the php's.

 

The new problem is it seems to have broken other scripts, i have a rating system on each page which no longer works when using the new links any idea what i need to look at to solve it?

 

Im calling the script with

<?php require('_drawrating.php'); ?>

 

and on the page

echo rating_bar('prod_num','');

 

It no longer seems to work, im not changing the name of _drawrating in the htaccess so im not sure whats up

 

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.