i am using the rewrite rules in htaccess but i am getting error on site,
while adding a / (slash) into the link
My Example Code:
RewriteEngine On
RewriteRule ^categories/(.*)$ ?act=directory&category=$1 [L]
actually i want to call this link from the category listing where the href link is
categories/category-name
now if i call this link like this
categories-category-name
then it works fine, but if i add the slash then the site looks as it doesnt have the css :(
only unstyled text i can see.
Thanks In Advance
Please Advise.
You need to add a slash in your css path
href="/css/your_style_name.css"
This will work
Related
I wrote the following codes with .htaccess
RewriteRule ^articles/([0-9a-zA-Z-_]+)$ page.php?article_seolink=$1 [NC,NE,L]
And I created the following URL address
example.com/articles/article-title
But I want to create a link like
example.com/article-title
How can I do this and redirect old URL to new one?
With your shown samples, please try following rules. Please make sure to place your htaccess Rules file inside articles folder. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^([0-9a-zA-Z-_]+)$ page.php?article_seolink=$1 [NC,NE,L]
I am having some issues trying to prettify some URL's. Basically I need to make this URL http://domain.com/actualfolder/fakepath/this-is-the-article.php to display content from this page http://domain.com/actualfolder/articlemanager.php.
The articlemanager.php is setup to receive a GET url variable in the way of the "this-is-the-article" and search for it in the database. If found, it will display content specific to that result. This part works.
The part that i can't make it to work is the htaccess rule.
This is my rule but it returns 404 not found or 500 if i don't use the initial slashes.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^fakepath/([^/.]+).php$ articlemanager.php?permalink=$1 [L]
I could really use some help, so any suggestion is welcome.
EDIT: the htaccess file lies in the domain.com/actualfolder/ location
We published an article in the magazine with following url:
http://magnetic-sleep-machine.com/moves
Now we need to make sure when people put that URL they land to
https://magnetic-sleep-machine.com/moves.html
Please help me figure this out! .htaccess or use a magento (1.7) option?
There's a way to redirect using magento, but not sure if that's exactly what you want.
You could also try turning on multiviews, and let mod_negotiation take cure of fuzzy URL-file mapping, in your htaccess file:
Options +Multiviews
Or using mod_rewrite:
RewriteEngine On
RewriteRule ^moves/?$ /moves.html [L,R=301]
Or using mod_alias:
RedirectMatch 301 ^/moves/?$ /moves.html
Okay I found the way to do it using magento itself.
created a new Page
page link named as "moves"
added javascript for redirect to body of the page
next went to system>config>web>
set Auto-redirect to Base URL to NO
Voila, it works now.
I have a link from anther website that I do not have control of http://example.com/one two three.exe
The correct URL is http://example.com/one_two_three.exe
Note the underscores instead of spaces.
I searched the internet and found this code snippet for .htaccess
# Redirect old file path to new file path
Redirect /one%20two%20three.exe http://example.com/one_two_three.exe
I added this snippet to my preexisting root .htaccess at the top of the file.
But it does not seem to work. My browser does not redirect and I get a 404 error page.
I believe that it has something to do with the spaces in the original URL but I don't know how to handle spaces in the URL.
Suggestions?
You could try a couple of things (both untested)
Redirect "/one two three.exe" http://example.com/one_two_three.exe
or use RewriteRule instead of Redirect:
RewriteRule /one\ two\ three.exe http://example.com/one_two_three.exe
I've added a .htaccess file to my root folder for the purposes of rewriting dynamic URLs into static ones. This seems to have been done successfully but I am having problems with page numbers.
For example, if you were to visit a static page /widgets, the first page of the products is fine....but subsequent pages show up as /products.php?cat=27&pg=2 etc. What I want is for subsequent pages to be in the form of /widgets-pg2 or /widgets?pg=2.
Below is my rewrite rule that I used for the initial category page:-
RewriteRule ^widgets$ products.php?cat=27
If any of you experts can help with this, it would be much appreciated.
Are you expecting the cat to change as well? You'd need to account for that in your URL as well:
e.g. www.site.com/widgets/27/2 could be rewritten as:
RewriteRule ^widgets/([0-9]+)/([0-9]+)$ products.php?cat=$1&pg=$2
If widgets will always be cat 27 then you can change it to:
RewriteRule ^widgets$ products.php?cat=27 [QSA]
which is query string append
Try
RewriteRule ^widgets-pg(.+)$ products.php?cat=27&pg=$1
After that, go here :)
To allow a query string after your rewritten URL use the [QSA] flag:
RewriteRule ^widgets$ products.php?cat=27 [QSA]
A link would than be:
http://example.org/widgets?pg=167&perpage=100&tralala=Hi!
I tried the following but it resulted in a '404 Not Found' error when I go to /widgets:-
RewriteRule ^widgets-pg(.+)$ products.php?cat=27&pg=$1
And I tried the following:-
RewriteRule ^widgets$ products.php?cat=27 [QSA]
This worked correctly but to go to page two of the widgets page, I need to type in the browser:-
/widgets?pg=2
But the actual 'page 2' link still leads to:-
products.php?cat=27&pg=2
So apart from a rewrite rule....maybe I need a separate redirection rule? Or maybe need to change the page number links. But since these are dynamically generated, I'm not sure how to do this.
The following is the PHP code for the page:- http://freetexthost.com/3ubiydspzm