hello ppl :)

i use .htaccess for my PHP site to redirect without changing the URL in the adress bar

for example: http://www.example.com/news/This.is.a.new

my .htaccess sends from /news/ folder sends the user to http://example.com/news.php?id=142151 ... and i can't send another variable to the http://www.example.com/news/ folder because is redirected to news.php?id... i want to do a category Sports for example http://www.example.com/news/Sports/ and not being redirected!

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^([^/]+)/(.*)$ news.php?id=$1 [L]

how can i change the Rule in .htaccess to send (subpages) to http://www.example.com/news/index.php?page=sports for example! ?

any ideea?:) thanks!

Recommended Answers

All 3 Replies

If your $_GET:

AddType text/x-component .htc
AddType application/x-httpd-php .html
Options FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ index.php?page=$1 [L]

piotrekw, the problem is that all the pages are going to be redirected to index.php?page=$1 , i don't want this, i already have this for redirecting to news.php?id=$1 , i want to keep this and add an if like:

IF cond.. = "Sports" then RewriteRule ... index.php?page=$1 ELSE RewriteRule news.php?id=$1

this is what i want :D the get the "cond.." check it if is ID or a sub page like Sports , Business , ... and then redirect to the page i want index.php or news.php
thanks for you reply! :)

finaly.. i found a way!!!

this is my code:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} ^[^A]+Sports.*
RewriteRule ^(.*)$ /news/index.php?cat=sports [L]
RewriteCond %{REQUEST_URI} ^[^A]+Business.*
RewriteRule ^(.*)$ /news/index.php?cat=business [L]
RewriteRule ^([^/]+)/(.*)$ news.php?id=$1 [L]

thanks for the help! hope my code will help other ppl, bye.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.