I have looked and keep finding really similar solutions and I managed to get it working halfway.
Solved first half:
entered url: wildcard.domain.com points to domain.com/wildcard (and doesn't change url) GREAT!
the .htaccess file code below does this.
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.pagebyme\.com$ [NC]
RewriteCond %{REQUEST_URI}::%1 !^/([^/]+).*?::\1
RewriteRule ^(.*)$ /%1/$1 [L]
Problem 2: if entered url is wildcard.domain.com/admin shows wildcard.domain.com/wildcard/admin
I don't want wildcard to show the second time. I just want the url to be wildcard.domain.com/admin
What rule do I need to add?
This is my first time using stackoverflow. Thanks in advance.
Related
I have a URL like this :
https://example.com/coins/1&order_by=today and several categories such as:
https://example.com/coins/1&order_by=new
https://example.com/coins/1&order_by=trending
You can also change the page so it will be 2 instead of 1 etc.. like : https://example.com/coins/2&order_by=today
I would like to change these to have https://example.com/today?page=1 etc instead of this above
I have read many responses on this subject and I searched the web, but unfortunately no solution works.
I tried this but it does not works:
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*&)?order_by=new(&.*)?$
RewriteRule ^(.*)$ $1?new/%1/%2 [L]
Try following htaccess Rules, please make sure to place these Rules at top of your htaccess file. Make sure to place your htaccess file inside root folder along with coins folder(not inside coins folder).
Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteBase /
RewriteCond %{THE_REQUEST} \s/coins/(\d+)&order_by=(\S+)\s [NC]
RewriteRule ^ /%2?page=%1 [R=301,L]
I'm try to make one trick for my webpage but I don't have any idea to make it that.
if my url is
mydomain.com/eu/en/home/11-item-item.html.
I want to add this ?SubmitCurrency=anything&id_currency=1 in last of that url.
But just only for one time adding this and not showing users is this possible?
Try:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(eu/en/home/11-item-item\.html)$ $1?SubmitCurrency=anything&id_currency=1 [L]
I looked through other stack overflow questions and I couldn't find one that was my exact case.
I have tried writing several different .htaccess rewrite rules but I can't seem to get it working.
I need to do the following:
Original URL: testexample.com/tool/1
Needs to redirect to: textexample.com/tool/display.php
But the URL in the browser needs to stay : testexample.com/tool/1
Can anyone point me in the right direction for rules for this rewrite?
You may try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !display\.php/? [NC]
RewriteCond %{REQUEST_URI} ^/([^/]+)/?.*/? [NC]
RewriteRule .* %1/display.php [L]
Maps silently
http://testexample.com/anything/folder (Shown in the browser all the time)
To
http://textexample.com/anything/display.php
----EDIT---
I have just realized that my explanation of the problem was missing an important piece of information.
The URL's should only be redirected if second parameter is present.
So the rule should read:
Redirect any URL that has /d/ in it, ONLY if /d2/ is also found in the URL.
----End Edit__
I have the need to 301 redirect all URL's on a site that contain a specific parameter to the same URL, but with an additional directory included. All of the URL's that require redirection contain a certain directory: /d/ Example:
http://www.mysite.com/category1/d/subcategory1/subdirectory2/
--Should Redirect to --
http://www.mysite.com/newdirectory/category1/d/subcategory1/subdirectory2/
The one thing in common with any of the URLs' requiring redirection is that they all contain a directory /d/ in the URL, which always immediately follows the "category" directory as indicated in bold in sample URL's above. I would then like to insert an additional directory in front of the category directory as indicated in bold in the sample URL's above. The rest of the URL will remain the same.
Can anyone help with this? I'm relatively new to mod_rewrite and realize I can make a big mess if I don't get it right.
Thanks in advance for anyone who can offer hlep
:)
Try this (edited to reflect change in question):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^.*/d/.* [NC]
RewriteCond %{REQUEST_URI} ^.*/d2/.* [NC]
RewriteCond %{REQUEST_URI} !/newdirectory/ [NC]
RewriteRule ^(.*)/d/(.*)$ http://www.mysite.com/newdirectory/$1/d/$2 [R=301,L]
Try adding the following to your htaccess file in the root directory of your site.
RewriteEngine On
RewriteBase /
#if the url contains a /d2/ [NC]
RewriteCond %{REQUEST_URI} /d2/ [NC]
RewriteRule ^([-a-zA-Z0-9]+/d/[-a-zA-Z0-9]+/[-a-zA-Z0-9]+/)$ /newdirectory/$1 [L,R,NC]
I have a domain at example.com
There is a subdirectory that has a quiz on it, located at example.com/quiz/?id=1
I need to change the ?id=1 to TakeTheQuiz so it would look like example.com/quiz/TakeTheQuiz
Here is what my .htaccess looks like right now (the .htaccess is located in the root direct at example.com). Right now I always get a server 500 error.
RewriteEngine On
RewriteBase /quiz
RewriteRule ^?id=1$ TaketheQuiz
This is really simple and all of the examples I have seen have been really complicated and hard for me to apply it to this one :( Help, anyone? Thank you for your time.
You've just got the rule the wrong way round:
RewriteEngine On
RewriteBase /quiz
RewriteRule ^TaketheQuiz$ ?id=1 [L]
EDIT
Per your comment try this instead:
RewriteCond %{QUERY_STRING} id=1
RewriteRule ^$ TaketheQuiz [R=301,L]