i have reading different post but was't able to implement on my htaccess.
i have a url when i search on the page i get this url http://doman.se/module/spsearchpro/catesearch?fc=module&module=spsearchpro&controller=catesearch&orderby=name&orderway=desc&cat_id=2%2C4%2C9%2C6%2C5%2C10%2C8%2C7%2C11%2C36%2C37%2C50%2C21%2C29%2C22%2C24%2C23%2C53%2C31%2C30%2C32%2C52%2C12%2C13%2C39%2C25%2C14%2C33%2C34%2C43%2C35%2C44%2C40%2C51%2C15%2C16%2C20%2C19%2C41%2C49%2C42%2C46%2C45%2C48%2C27%2C38%2C28%2C47%2C54%2C55%2C56&search_query=general&spr_submit_search=Search&n=30
how can i remove the numbers 2%2C4%2C9%2C6%2C5%2C10%2C8%2C7%2C11%2C36%2C37%2C50%2C21%2C29%2C22%2C24%2C23%2C53%2C31%2C30%2C32%2C52%2C12%2C13%2C39%2C25%2C14%2C33%2C34%2C43%2C35%2C44%2C40%2C51%2C15%2C16%2C20%2C19%2C41%2C49%2C42%2C46%2C45%2C48%2C27%2C38%2C28%2C47%2C54%2C55%2C56
or make the url like this
http://doman.se/search_query=general
Related
Our old website has a search URL structure like this:
example.com/Country/United States/Region/California/Area/Southern California/City/San Diego/Suburb/South Park/Type/House/Bedrooms/4/Bathrooms/3/
This is currently rewritten to point to the physical page:
/search/index.aspx
The parameters in the URL can be mixed up in different orders, and the URL can include one or more parameters.
We want to 301 redirect these old URLs to a new structure that is ordered in a logical way and more concise:
example.com/united-states/california/southern-california/san-diego/south-park/?type=house&bedrooms=4&bathrooms=3
example.com/united-states/california/?type=house&bedrooms=4&bathrooms=3
Is there a way with URL rewriting to interrogate the old URL, work out what parameters are existing and then write out the new URL structure?
Even if we can limit it to just the Country, Region, Area, City and Suburb, that may be good enough to at least return some results even if it's not perfect.
Also, spaces should be turned into hyphens and all text made lowercase.
I already have the RewriteRule to turn the new URL structure into a URL to point to a physical page. It's just transforming the old URL in to the new URL I need help with. I've googled endlessly and it's just beyond me!
Can anyone help? Thanks.
Since you already have the old search page with rewriting rules set up for it and which is capable of parsing all parameters you need, the easiest and most appropriate solution I see here is to issue a redirect you require from this old search page's code. Just put the code that composes new URL with all parameters needed and redirects from this page - this should be a lot easier than trying to parse all these parameters in .htaccess and combine them into the new format.
I have a series of URLs on my website:
http://www.example.com/sub1/sub2/content.html
But I would like to remove "sub1" completely - not hide it so it still attempts to access that directory. Finished result would be this URL:
http://www.example.com/sub2/content.html
Many similar posts on SE seem to demonstrate how to "hide" a URL from the user. I want to rewrite the URL so that it treats it as if it isn't even there.
Example of what I'm trying not to do: Hide Part of URL htaccess
NOTE: I do not want to actually delete files as suggested by the comment below. I'm trying to redirect the request to another directory.
This worked for me:
RewriteRule ^sub1/sub2/(.*)$ /sub2/$1 [R=302,NC,L]
Helpful page: http://coolestguidesontheplanet.com/redirecting-a-web-folder-directory-to-another-in-htaccess/
I'm new to using the URL Rewrite module and I'm having trouble with what I thought would be a simple URL rewrite for forum threads (using IIS 7.5)
I need to rewrite:
/forum/100/2534/friendly-title
or:
/forum/100/2534/334/comment/friendly-thread-title
to:
/forum/?forum=100&thread=2534&post=334&postType=comment
The rule that I have written (not working) is:
^forum/([1-9][0-9][0-9]*)/([1-9]*)/(([1-9]*)/(post|comment)/)?([a-zA-Z0-9-]{5,50})$
Which maps to:
/forum/?forum={R:1}&thread={R:2}&post={R:4}&postType={R:5}
I'm getting a 404 error.
It's correct that {R:4} and {R:5} are empty when you use the first URL. That's because there are no values for these fields. The RegEx still matches though so the URL will still be rewritten. Your code should properly handle empty values for the post and postType querystring parameters to display the entire thread and not just a specific comment (at least that what I assume is suppose to happen).
By the way, a more logical URL structure would be:
/forum/100/2534/friendly-thread-title/comment/334
This won't help you this this particular problem though but just on a side note.
I have urls structured like this:
/!#/pretty-url/
I need to remove the !# so the urls will look like this:
/pretty-url/
What would be the correct .htaccess rule to do this?
When you have a # in the URL then that is a named anchor. The browser does not send anything to the right of a # to the server. This means that all the rewrite engine is seeing is:-
/!
If you want your URLs to look like this then you are going to need to use JavaScript to get the relevant content via AJAX.
I have a search engine on my site with two search parameters, location and query. I want to show the results on a page with the canonical URL of /search/location/query.
I tried aiming the search at a non-existant PHP file which I could then rewrite using my .htaccess:
# search bar rewrites
RewriteRule ^search.php?query=([A-Za-z_-]+)&location=([A-Za-z_-]+)$ /search/$1/$2/ [R]
This doesn't seem to be working, however, and after setting my search form to post GET to search.php I just get a 404. I would prefer not to have to use Javascript to submit the form directly to the canonical url - any way I can rewrite it dynamically with mod rewrite?
Wouldn't the better approach be to change the form from a get to post?
Generally pretty URIs are for actual locations rather than search results.