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 8 years ago.
Improve this question
I am completely new to ht-access and I am not sure that this is the correct way to do this.
On my WordPress site, I have the current url:
http://www.example.com/category/travel/
And would like to map this to:
http://www.example.com/kids-vaction-spots/
So any post under the category travel would look like:
www.example.com/kids-vaction-spots/beach-holidays
Is it possible to have a rule in the htaccess that does this?
Thank you for taking the time to look at this.
Try adding these rules to the htaccess file in your document root. Make sure they're above any rules that do routing for a CMS.
RewriteEngine On
RewriteRule ^/?category/travel/(.*)$ /kids-vacation-spots/$1 [L,R=301]
Related
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 5 days ago.
Improve this question
Please can you help to correct a rewrite rule on a wordpress website.
My urls are like this one :
https://mywebsite.fr/activity/city/?location_search=city+region+country+&tax-listing_category=Activity
I want this url :
https://mywebsite.fr/activity/city/
So I need to remove everything after "activity/city/"
I tried this but not working :
RewriteRule ^([-a-z_]+)/([-a-z_]+)$ /$1/$2/^ [NC,L,QSA]
EDIT :
The urls are like this because it's wordpress pages (hierarchical structures parent-page/child-page/) and I add in the urls parameters to pre-fill the search-form in the page
You can have a look here : bit.ly/3RUybZD
If you try to remove all parameters from the url, you will see the search-form and listings updated
Thx
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 1 year ago.
Improve this question
I have a URL that with some parameters. One of the parameters called 'lang' and it looks like this:
https://example.com/example1/?id=1&lang=en
I want to redirect all the current URL with lang=en to lang=gb
https://example.com/example1/?id=1&lang=gb
Note: the example1 folder is an example and it doesn't a constant variable.
every URL contains a different folder name.
This probably is what you are looking for:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^(?:(.*&)?)lang=en(?:(&.*)?)$
RewriteRule ^ %{REQUEST_URI}?%1lang=gb%2 [R=301]
It is a good idea to start with a R=302 temporary redirection and only to change that to a R=301 permanent redirection once everything works as expected. That prevents nasty caching issues.
In general you should prefer to implement such rules in the actual http server's host configuration. Distributed configuration files (".htaccess") should only be used if no other alternative exist. They come with a number of disadvantages.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
Please I have this url
http://sub.maydomaine.com/wallpapers.php?category=cities&name=San%20francisco
I want redirect to
http://sub.maydomaine.com/wallpapers/cities/San%20francisco
Please help me .
If you add this rewrite rule, you should be able to support both urls:
RewriteRule ^wallpapers/([^/]+)/([^/]+)$ wallpapers.php?category=$1&name=$2 [QSA]
Hope this helps.
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 9 years ago.
Improve this question
I want to redirect this url:
domain.asd/category/node123/attachment/file123
to this one:
domain.asd/category/node123
by removing the attachment/fn1aa from the end.
Only the node123 and the file123 are dynamic.
The code below working, but it's valid, safe and resource-friendly?
RedirectMatch permanent category(.*)attachment /category/$1
Any recommendation are welcome. thx.
Try:
RedirectMatch permanent ^/category/([^/]+)/attachment /category/$1
It's more strict and won't duplicate forward slashes (/). Your regex will also match things like this:
domain.asd/foo/something/category/a/b/c/d/e/f/some-attachment
by redirecting to:
/category//a/b/c/d/e/f/some-
which probably isn't what you want to do. It's safe and as resource friendly as it is using an htaccess file (which is slight performance hit as opposed to putting this in the vhost config).
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 8 years ago.
Improve this question
I have a problem with a url a .htaccess.
I need that all url like : http://mywebsite.com/api/something go to my api/index.php cause I need to write a routing system from this place.
The .htacces must be inside the api/ folder.
What I'm trying to do here ,is a routing system who includes differents content inside the api/index.page depending on the url used.
For exemple if I go to http://mywebsite.com/api/activity I want to include a specific file without changing the url.
Do you think it's possible ? Have you an idea of the .htaccess content ?
Thanks for your help.
I've finally found the solution by myself so I post the solution, that may help another person later :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (.*) index.php [PT,QSA]
</IfModule>