Rewriting a Word in URL - apache

I'm having trouble remove a word from a URL
I want to remove the word 'index' from a URL, I just don't know the code to do it.
I was thinking something like the following:
RewriteRule www.example.com/$ www.example.com/index/$1
Sorry I can't really do much more.
Thanks in advance everyone!

I guess you are using apache.
Use:
RewriteCond %{REQUEST_URI} ^\/index[\/]*$
RewriteRule (.*)$ / [QSA,L]

Related

Rewrite Rule - need guidance

I need to do some redirecting to get some internal links to work but I'm having a complete block.
The url would be http://www.something.com/faqs/What_happens_if_I_move_home?
redirected to http://www.something.com/faqs/index/What_happens_if_I_move_home?
but it must look like the original url. I'm sure there is a simple answer but rewrite rules and regex are a mystery to me at times.
I did try RewriteRule ^faqs(/.*)?$ /faqs/index$1 [R,L,NC]
amongst many others!
try this:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/faqs/index
RewriteRule ^faqs/(.*) /faqs/index/$1 [L,NC]

.htaccess url parameter rewrite for specific page

I have been battling for hours now and searched Google and StackOverflow, without a solution to my problem, hope you guys can help! :-)
I have a page with parameters as follows: profile?userid=123456789. I want it to rewrite to profile/123456789. This I have, but now everywhere on this page all links gets /profile/link. Is there any fixes to this? Thanks in advance, here comes my .htaccess code.
RewriteEngine on
RewriteCond %{REQUEST_URI} !/profile\.php
RewriteRule ^profile/([^/]*)$ /profile?userid=$1 [L,QSA]
try this, it works for me with many configurations
RewriteEngine On
RewriteRule ^profile/([^/]*)$ /profile?id=$1 [L]
if you want the ([^/]*) to be exclusively number, you'll need to use PHP to rewrite your urls
You can change your rule parameter order as below to make it work
RewriteEngine on
RewriteRule ^profile?userid=([^/]*)$ profile/$1 [L]
Hope this will help you :)

Single case - dynamic to static page using modrewrite in htacess

I have one dynamic page:
http://blog.mysite.com/?p=25
and with htaccess and modrewrite, I want to change it to:
http://www.mysite.com/stuff/newhome.html
I know it can't be that hard but this one has me stumped, any and all help will be greatly appreciated.
EDIT
I tried:
RewriteRule ^p=25 mysite.com/stuff/newhome.html [QSA,R=301,L]
Along with variations but no success.
RewriteCond %{QUERY_STRING} ^p=25$
RewriteRule ^$ http://www.mysite.com/stuff/newhome.html [R=301]

Why is my simple rewrite code causing a redirect loop?

Would greatly appreciate it if someone could help me make this work.
I'm trying to make domain.com/painting.php?name=hello redirect to domain.com/page/hello while keeping my rewrite :
RewriteCond %{QUERY_STRING} name=([^&]+)
RewriteRule ^painting\.php$ /page/%1? [R=301,L] #redirects to page
RewriteRule ^page/([^/\.]+)/?$ painting.php?name=$1 [L] #rewrites painting
I would like to keep only the "pretty url". Please help.
Found answer here: simple 301 redirect with variable not working, why?
I'm assuming what you actually want to do is be able to accept the URL domain.com/page/hello and rewrite it (invisibly) to domain.com/painting.php?name=hello. If so, try this
RewriteRule ^page/([^/.])+/?$ painting.php?name=$1 [QSA,L]

Beginner's apache mod_rewrite assistance

I am not really familiar with apache mod_rewrite.
I have url parameters such as {domain}/index.php?blog=5
I simply want to make it {domain}/home.php?client=5
Is it a task as simple as it sounds and can anyone help?
The following might work, give it a try
RewriteCond %{REQUEST_URI} ^/home.php [NC]
RewriteCond %{QUERY_STRING} client=([0-9]+) [NC]
RewriteRule (.*) http://%{REMOTE_HOST}/index.php?blog=%1 [L]
That seems pretty simple, to be honest — once you get your head into mod_rewrite, it's not that complex.
It sounds like you want to add
RewriteEngine on
RewriteRule ^/index.php?blog=(.+)$ /home.php?client=$1
to your configuration.
Some caveats:
If you are putting this in a .htaccess file, then remove the / from the RewriteRule line.
If you want to make this case-insensitive, add [NC] to the end of that same line.
If you want users to see the URL change (so sending a 302 Found redirection to the browser), then add [R] to the end of the RewriteRule line.
If you want both a 302 Found and for the URL to be case-sensitive, combine the two instructions as [NC,R] at the end of the RewriteRule line.
It's definitely worth reading the mod_rewrite docs, but the rule above should be all you need for this use-case.