I have the following Short-hand for a user profile url
RewriteRule ^(\w+)/?$ ./profile.php?name_of_user=$1
The site is styled with the appropriate css file when i do site.com/name_of_user
but not when i do site.com/name_of_user/
Although the redirect is to the right page...
Help is appreciated!
Use a 301 redirect . htaccess to point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the "example.com" domain.
htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.
Creating a redirect rule Within the Edit Rule page, enter the following: Name: Redirect from blog (This is a unique name for the rule.) Pattern: ^blog/([_0-9a-z-]+)/([0-9]+) (This pattern will match the URL string that starts with "blog" and captures the second and third segments of the URL into back-references.)
the easiest way to fix this is to specify the full path to your CSS file in the <head>
of the HTML file.
If your mod_rewrite rule is modifying the path to where your CSS file is, you'd also want to place this before your RewriteRule
:
RewriteCond %{REQUEST_FILENAME} !-f
This makes sure that the request doesn't match a file before rewriting it.
I had this same problem and have found the easiest and most practical solution.
<base href="http://www.example.com/" />
It's super clean and easy to use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With