I have a website in php which has some pages:
www.example.com/news
www.example.com/people
www.example.com/music
On each of these pages is an overview of content. If you click, for example, on a link on www.example.com/news, an article opens with that url using a template (www.example.com/article.php?url='example-of-article-url')
For each of these pages there is a rewrite needed. The displayed url should be www.example.com/news/example-of-article-url
and this should acces the article.php file. The news directory is virtual. The www.example.com/news, www.example.com/people, www.example.com/music are being rewritten by this code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
What I have been trying is:
RewriteRule ^news/(.*) article.php?url='$1' [R=301,L]
However, when this is loaded, css and images aren’t. The content is generated thinking it’s in the /news/ directory, thus unable to find the other files. I can’t use canonical URL’s because of SEO-reasons.
2
Answers
First of all dont forget to add this at the very start:
Remove the Qoutes from ‘$1’ your last line and try the method below instead.
To redirect with the contents of a whole directory to your location:
Or you can do it this way too with a Slash on the Start:
Redirect the whole folder (news) to your new location:
or
To redirect with the contents of a whole directory to your location:
Best of Luck
You should add:
In your
<head>
section.