How do I remove subfolders names from URL?
For example:
mywebsite.com/wp-contents/uploads/2019/02/image.jpg
mywebsite.com/wp-contents/uploads/user/demo/2019/02/image2.jpg
Then the same URL without the subfolder's name:
mywebsite.com/uploads/image.jpg
mywebsite.com/uploads/image2.jpg
INFO: I can only use .htaccess to achieve this.
Try this rules in your .htaccess file
RewriteEngine On
RewriteRule ^uploads\/image\.jpg$ /wp-contents/uploads/2019/02/image.jpg [L]
RewriteRule ^uploads\/image2\.jpg$ /wp-contents/uploads/user/demo/2019/02/image2.jpg [L]
another rule for all /uploads/image***.jpg to /wp-contents/uploads/2019/02/image***.jpg
RewriteEngine On
RewriteRule ^uploads\/(.*)$ /wp-contents/uploads/2019/02/$1 [L]
I have a url http://www.example.com/chatroom/chats.php?chat=hey dear
I want a url to be http://www/example.com/chatroom/chats/hey dear
where chatroom is an alias folder.
my apache document root is pointing to a specific folder as DocumentRoot
/var/www/html/myweb
I am trying like
RewriteEngine on
RewriteBase /
RewriteRule ^chatroom/([A-Za-z0-9-]+)/?$ chats.php?chat=$1 [NC]
Its saying
404 not found.
Set QSA flag for your rule and try
RewriteRule ^chatroom/(.*) chats.php?chat=$1 [QSA,L]
QSA - Query String Append
You need to place a .htaccess file in chatroom folder with the following content.
Options +FollowSymLinks
RewriteEngine on
RewriteRule chats/(.*) chats.php?chat=$1
Or the following if placing in root folder
RewriteEngine On
RewriteRule ^([^/]*)$ /chatroom/chats.php?chat=$1 [L]
Here are some tools which might help you to generate the such code.
http://www.generateit.net/mod-rewrite/index.php
http://www.webconfs.com/web-tools/url-rewriting-tool/
I want rewrite below url
http://www.example.com/page.php?n=About%2BUs&id=F534Z531G538
to
http://www.example.com/about-us
using .htaccess file.
i have tried below code in my .htaccess
Options +FollowSymlinks
RewriteEngine on
rewriterule ^page.php?n=About%2BUs&id=F534Z531G538(.*)$ http://www.example.com/about-us$1 [r=301,nc]
but this is not working and also id is randomly generate.
anyone can help me ?
try this
RewriteRule ^about-us/([a-zA-Z0-9]+)$ page.php?id=$1
for http://www.example.com/about-us/f14dfa
for http://www.example.com/about-us
RewriteRule ^about-us$ page.php
My mediawiki's localproject name is "wiki_test".and i use following code for localsettins.php file
$wgScriptPath = "/wiki_test";
$wgArticlePath = "/wiki/$1";
require_once("$IP/extensions/ShortUrl/ShortUrl.php"); //
and create one file in the root(means in my project folder) .htaccess file.and put following code in that
RewriteEngine On
# Short url for wiki pages
#RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/mediawiki_test/index.php/ [L]
# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/mediawiki_test/index.php [L]
and try for short url but give error like"Object not found!". so plz give me idea........
If you are placing your .htaccess in mediawiki_test directory then this code should work:
RewriteEngine On
RewriteBase /mediawiki_test/
RewriteRule ^index\.php$ - [L]
RewriteRule ^ index.php [L]
In order to convert my dynamic URL i.e www.3idiots.co.in/index.php to static url i.e www.3idiots.co.in/index.html, I edited my .htccess file and put the following code in it:
RewriteEngine On
RewriteRule ^index.php$ /index.html [R]
when i uploaded this file in the root directory,and try to open the page, I got the error
404 page not found error, www.3idiots.co.in/index.html not found.
You have to actually have a file named index.html. Right now you don't. The rewriting/redirecting is working fine, you're just redirecting to a non-existent page/file.
I'm a little confused as to what you're actually trying to do. If you just want to move index.php to index.html, rename the file. Rewriting makes it so that if someone tries to open index.php they will be redirected to index.html, but you still have to have an index.html file for them to be redirected to.
RewriteEngine On
# Send the user to index.html
RewriteRule ^index.php$ /index.html [R]
# Tell the server that index.html really means index.php
RewriteRule ^index.html$ /index.php
Try these rules:
RewriteCond %{THE_REQUEST} ^GET\ /index\.php
RewriteRule ^index\.php$ /index.html [L,R=301]
RewriteRule ^index\.html$ index.php [L]
The first rule redirects every direct request of /index.php externally to /index.html. And the second rule rewrites requests of /index.html internally to /index.php.
Are you sure mod rewrite is enabled & working?
1) create an html page called found.html with whatever you want in it, but some text to be sure it's loaded (not a blank page basically) and put this in an file called ".htaccess" :
RewriteEngine on
RewriteBase /
RewriteRule ^find.html$ /found.html [L]
2) upload both your .htaccess and the found.html files in your domain's root
3) Just try to load -www.example.com/find.html (with your real domain of course). If mod_rewrite is available, you should see the content of found.html while browsing find.html (which does not physically exist by the way).
If it does not work, try :
RewriteEngine on
RewriteBase /
RewriteRule ^find.html$ found.html [L]
In the Apache Conf file, you also need to make sure that AllowOverride is set to a value that will allow .htaccess to be processed.
Normally it's AllowOverride all
RewriteEngine On
RewriteRule ^index.html$ index.php
RewriteRule ^$index.htm/$ index.php [L]
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^index.html$ index.php
Try this code...
It will work for your problem /..
Best Of LUck
If it solve your problem..
Visit my site