0

I have a simple php form that uses action="index.php", so when the form is submitted I get this: dev.mysite.net/apps/myapp/r4/index.php

But I would like it to display as: dev.mysite.net/apps/myapp/r4/results/

This is what I have so far, but it is not working:

RewriteEngine On
RewriteBase /
RewriteRule ^dev.mysite.net/apps/myapp/r4/index.php? dev.mysite.net/apps/myapp/r4/results/ [NC,L]

I am new to URL rewriting so any help would be great.

0

2 Answers 2

1

You can use this rule in your .htaccess to remove index.php from your URL:

DirectoryIndex index.php
RewriteEngine On

# remove index.php
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE]
Sign up to request clarification or add additional context in comments.

Comments

0

Try flipping it around. You're rule says if you match dev.mysite.net/apps/myapp/r4/index.php then send it to dev.mysite.net/apps/myapp/r4/results/ ... but you want it the other way around. You should also leave off the domain and only include the path.

RewriteRule ^apps/myapp/r4/results/$ /apps/myapp/r4/index.php [L]

Here we look for a request for /apps/myapp/r4/results/ and send it to /apps/myapp/r4/index.php without a redirect. If you include a domain on where you want to send the request, even if it's the same domain, it will perform a redirect.

2 Comments

No, I need the URL to display as 'dev.mysite.net/apps/myapp/r4/results/'. It currently shows ..r4/index.php, which I do not want.
searchfriendlyurls.com Go put in your URL, the old path, and the new path and see what it gives you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.