Rewrite specific url using htaccess - .htaccess

I have a custom php file at the following url
http://www.paradox4a.com/wp-content/themes/whitetheme/custompage.php
I want the user to visit the above link using a virtual url like that
http://www.paradox4a.com/activate/
Is that possible using the .htaccess rewrite_mod ?

In the htaccess file in your document root:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^activate/$ /wp-content/themes/whitetheme/custompage.php [L]

Related

htaccess not working in sub directory

My website is hosted in a sub directory (http://example.com/folder).
In root directory I forward http://example.com to http://example.com/folder where I have created a blog page and I rewrite URL like this:
RewriteEngine On
RewriteRule ^([^/]*)-(.+)\.html$ \/folder\/blog\.php?title=$1&bid=$2 [L]
This is working but it affecting other folder URL means like http://example.com/folder2 who will be redirected to my blog.
You can check if the directory or the file really exist and not apply the redirection with conditions:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)-(.+)\.html$ \/folder\/blog\.php?title=$1&bid=$2 [L]

Using the .htaccess to redirect all of a site minus the system folder for expression engine

I would like to redirect everything from a site oldblog.com to newsite.com/blog/ with the exception of being able to access oldblog.com/system/ and all the files within in it.
This is because of Expression engine is on this domain and the other sites need to access this to change stuff.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !^(blog|system)(/.*)?$ blog%{REQUEST_URI} [L,NC]

Removing 2 directory and php from url

My current url is:
http://example.org/dir1/dir2/profile.php?username=someone
I want it to look like this:
http://example.com/someone
My .htaccess file is in public_html folder and it is completely empty.
Please, can you help me?
Try this :
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_-]+)/?$ /dir1/dir2/profile.php?username=$1 [QSA,L,NC]
The conditions make sure you don't rewrite any existing file/directories on the server.

htaccess rule to redirect user without page name

My index.php page redirect to this type of url after process results.php?token=0e635edc03.
Now I would to to hide the results.php. So just: domain.com/0e635edc03.
Do I need a .htaccess rule ?
Which .htaccess rule I need to perform it ?
Thanks.
Try adding this to the htaccess file in your document root:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9a-f]+)$ /results.php?token=$1 [L,NC]
now you need to make sure the index.php file redirects to domain.com/0e635edc03 instead of the results.php URL.

htacces rewrite url - redirect folder to php file

I want to redirect or rewrite sub directories to PHP files
Such as:
http://www.domain.org/contact
to this:
http://www.domain.org/index.php?sub=contact
I would REALLY like it is PHP could just read domain.org/contact as domain.org/index.php?sub=contact, but if it just redirects that way I'll be happy! I've searched for many solutions using .htaccess, but they are unclear or I can't get them to work specifically for what I am attempting to do
Thanks
Try this
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?sub=$1

Resources