This is an example of how I want the URL to be rewritten:
Visible url is localhost/foldername/task/task_title/task_id
Back End Url is localhost/foldername/task.php?task_id=1213
I wrote this line in my .htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /task/[a-zA-z0-9]+/([0-9]+) /task.php?task_id=$3
#front url: task/task title/taskid#
#back_end url: task.php?task_id=1233
This does not work and shows errors "Internal Server Error" and "The server encountered an internal error or misconfiguration and was unable to complete your request.".
How do I have to fix my rewrite rule for these type of urls?
The rules would be:
RewriteEngine On
RewriteRule ^(foldername/task)/[a-z0-9]+/(\d+)/?$ /$1.php?task_id=$2 [NC,L]
Related
I have a link like this:
http://www.expamle.com/folder1/folder2/folder%20/file.html
I want to 301 redirect it with .htaccess to:
http://www.expamle.com/folder1/folder2/folder/file.html
I tried this:
RewriteCond %{REQUEST_URI} ^\/folder1\/folder2\/folder\%20\/file\.html$
RewriteRule .* http://www.example.com/folder1/folder2/folder/file.html [R=301,L]
but I'm getting:
Not Found
The requested URL /folder1/folder2/folder /file.html was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I also tried this
Redirect 301 /folder1/folder2/folder%20/Export1.htm http://www.example.com/folder1/folder2/folder/file.html
but got the same error.
What am I doing wrong?
The solution is to add quotes like this:
Redirect 301 "/folder1/folder2/folder /Export1.htm" http://www.example.com/folder1/folder2/folder/file.html
Im having some troubles with the redirection rules on my .htaccess file.
I would like to create a rule to redirect my blog content to a friendly url.
The current url structure is:
/blog/article.php?id=hello
and I would like it to change to:
/blog/hello.html
This are my rules so far, and I dont seem to be able to find the error:
RewriteEngine On
Options -MultiViews
RewriteRule ^blog/([a-z,A-Z,0-9]+)$.html blog/article.php?id=$1 [L]
Any help would be appreciated.
Because of your placement of $ in the pattern, the rewrite module is unable to match your request to the expression.
It should be:
Options -MultiViews
RewriteEngine On
RewriteRule ^blog/([\da-z]+)\.html$ blog/article.php?id=$1 [L,NC]
I've made a redirect in a htaccess file:
Redirect 301 /example.com/oldAddress http://www.example.com/newAddress.php
ErrorDocument 404 /index.php
But it generates this url:
http://www.example.com/newAddress.php?redirect=1
so it causes a 404 error. How can I make it work?
put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^oldAddress http://www.example.com/newAddress.php? [L,NC,R=301]
? in the end will target any existing query string.
I have this url:
http://www.mydomain.com/search.php?title=beatiful%2Fcat
I need rewrite it to:
http://www.mydomain.com/beatiful+cat
I added this line in my .htaccess:
RewriteRule ^([^/]*)$ /search.php?title=$1 [L]
but without success.
Thanks in advance!
If you added:
RewriteRule ^([^/]*)$ /search.php?title=$1 [L]
to your htaccess file in your document root, and there aren't any other rules before it, then you shouldn't be getting a 404, you should be getting a 500 internal server error because these rules will loop infinitely.
This means either your htaccess file isn't being read or you don't have FILEINFO override rights in whatever directory the htaccess file is in.
I am trying to create search engine friendly URLs with the following .htaccess and it is directing to a 404 error page no matter what I try.
This is on a Host Gator shared account, if it makes any difference. The directory is (document root)/blog, the .htaccess file is located in the directory "blog."
Example URL would be http://examplesite.com/blog/category/announcements.Here is the .htaccess file contents:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^category/([a-zA-Z0-9]+)/$ index.php?category=$1
Any ideas why this is happening?
RewriteRule ^category/([a-zA-Z0-9]+)/*$ index.php?category=$1 [R=301,L]
Forget the preceeding slash?
RewriteRule ^category/([a-zA-Z0-9]+)/$ /index.php?category=$1