I have trouble in making fancy URLs with .htaccess
.
I'm saving titles in database like "name-of-a-title" but problems start when I try to access it from URL, it doesn't show me the CSS, only the content.
This URL for blog works like:
http://example.com/blog?title=page-title
and I need a URL like this
http://example.com/blog/post-title
Here is my file, I'm a beginner.
<files .htaccess>
order allow,deny
deny from all
</files>
RewriteEngine On
RewriteRule ^blog$ blog.php
RewriteRule ^blog/$ blog.php
RewriteRule ^blog/([^/]*)$ /blog?title=$1 [L]
RewriteEngine On
RewriteRule ^category/([^/]*)$ category.php?$1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# To externally redirect /dir/abc.php to /dir/abc
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [QSA,NC,L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [QSA,NC,L]
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^my-webiste.com
RewriteRule (.*) http://www.my-website.com/$1 [R=301,L]
RewriteEngine On
ErrorDocument 404 /404.php
You just need to update your HTML so it uses absolute links to reference the CSS, images etc. With your fancy URLs the browser is now starting from /blog/
instead of root to find them.