How to use url rewrite with parameters [closed] - .htaccess

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How to use url rewrite with parameters
example.com/news.php?id=1 to example.com/news/1
And the value of number will change dynamically.

RewriteEngine On
RewriteRule ^news/([0-9]*)$ /news.php?id=$1 [L]

Yes, there are many similar questions. But here is how to do it.
RewriteEngine On
RewriteRule ^news/([0-9]+)/?$ news.php?id=$1 [NC,L]
You should have mod_rewrite enabled in your server.

Related

htaccess redirect static to dynamic by extracting an ID from the URL [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a URL like
railroad-worker-decal-p-18196.html
I need to redirect it to
index.php?main_page=product_info&products_id=18196
How can I do this?
You need to capture the id and use it in the rewrite:
RewriteRule ^(.*)-p-(\d+).html$ index.php?main_page=product_info&products_id=$2

I want show different url and execute different url [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I want show below url
http://example.com/folder1
and execute url is
http://example.com/?test=folder1
In .htaccess file try this
RewriteEngine On
RewriteRule ^([a-z0-9_\-]+)$ index.php?test=$1 [L,NC]

301 complex redirection via .htaccess [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Hi Guys i'm currently in the middle of a migration, and need the clients traffic to be sent as a fail save the new url's.
The old domain would have something like olddomain.com/abcd/1234 and i need to redirect that to newdomain.com/?paramenter1=1234&parameter2=ABCD.
This is probably something easy to do and i'm guessing this can be done via a .htaccess request so we can make sure there's no left over traffic. I'm not a developer but i'm a techie and need to advise the client's tech on placing this one since this is actually my idea to help them out.
Any help would be much appreciated!
Thanks in advance!
The following .htaccess rule will redirect http://olddomain.com/abcd/1234 to http://newdomain.com/?paramenter1=abcd&parameter2=1234.
Notice that the two captured groups (defined by parantheses) from the regular expression are numbered from 1 and up. So the first captured group will be accessible in the redirect url as $1 while the second group will be accessible as $2. Please adjust accordingly to your requirements.
RewriteRule ^(.+)/(.+)$ http://newdomain.com/?parameter1=$1&parameter2=$2 [R=301,L]

.htaccess to allow #fontface [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am using the master .htaccess from http://docs.joomla.org
Its working well but its also locking out all my woff|eot|svg|ttf
How can I add these to the allowed filetypes?
My fonts reside in /templates/mytemplate/css/type/ folder
I believe this is the line in question:
## Allow limited access for certain Joomla! system directories with client-accessible content
RewriteRule ^(components|modules|plugins|templates)/([^/]+/)*([^/.]+\.)+(jp(e?g|2)?|png|gif|bmp|css|js|swf|html?|mp(eg?|[34])|avi|wav|og[gv]|xlsx?|docx?|pptx?|zip|rar|pdf|xps|txt|7z|svg|od[tsp]|flv|mov)$ - [L]
Basically, in certain folders - including the templates/ folder, only certain file types are being allowed and your files aren't in the list. Adding them in the final bracketed clause pipe separated should do the job. Something like...
RewriteRule ^(components|modules|plugins|templates)/([^/]+/)*([^/.]+\.)+(jp(e?g|2)?|png|gif|bmp|css|js|swf|html?|mp(eg?|[34])|avi|wav|og[gv]|xlsx?|docx?|pptx?|zip|rar|pdf|xps|txt|7z|svg|od[tsp]|flv|mov|woff|eot|svg|ttf)$ - [L]

htaccess redirect url parameter as segment [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Is it possible to redirect url parameters as segments in .htaccess file?
i.e.
test/index.php?parameter=MYVALUE
to
test/MYVALUE/
Yes. Try this:
RewriteCond %{QUERY_STRING} parameter=(.*)
RewriteRule test/index\.php test/%1
According to "What is matched?" in the mod_rewrite docs, the query string (part after the ?) is separated out into the QUERY_STRING variable, which then has to be tested separately from the main part of the URL. In RewriteCond, the parameter value is captured by the regular expression within the parentheses (.*), and is then available as %1 in the RewriteRule.

Resources