remove http query parameter from url htaccess - apache

I want to shorten my URI to just my site address that is
http://www.abcdef.org/index.php?pg=23
http://www.abcdef.org/histop.php?pg=1
http://www.abcdef.org/other.php?pg=29
to
www.abcdef.org
How can I rewrite this using my `.htaccess file? I read a lot of articles but could not find any solution.

Use Redirect directive
Redirect /foo.html /bar.html
Apache Documentation
But understand when the user types in whatever URL it will map to your index file in your case. But you can't just hide every URL to the domain name...it doesn't work that way.

Related

htaccess - Appending http_referer query string parameters to the requested uri using .htaccess

I am pretty new to htaccess and how to use them so you'l have to bear with me a little.
Example of what I am trying to achieve:
I am on a page with the following URL: https://www.example.com/you?source=hissite
While on this page I click on a link to another page of my site with an href of https://www.example.com/him.
Is it possible to use htaccess to append the parameters of the referal url into the requested url, this way I end up on https://www.example.com/him?source=hissite ?
This question gave me some good clues but I couldn't figure out how to append only the parameters. Redirect using htaccess based on referrer

Can I use .htaccess to convert a url slug to a POST request?

I would like to use .htaccess to take a URL like this:
mydomain.com/some-url-slug
and instead redirects the user to mydomain.com, but with a POST request that includes "some-url-slug".
Is this possible? Thanks!!
NO it's not possible - mod_rewrite rules cannot alter or rewrite POST data.
Obviously there are some security constraints in doing so, hence mod_rewrite developers didn't allow that.

Redirecting from example.com to www.example.com

My site uses AJAX, and it seems like I have to include the full path when I use it to access a function. This is fine, as I can code it in. The problem is, I have hardcoded http://www.example.com... but if a user has gone to http://example.com (without the www) this gives an access problem and the AJAX won't execute.
I think the easiest way to resolve this would be to make sure that if a user goes to mysite.com, they are redirected to www.example.com.
I can find solutions online, but they all involve the htaccess file, which my server doesn't support - I have to use rewrite.script instead.
How can I do this using rewrite.script, or is there an alternative way to approach this?
Thanks for the suggestions - I was directed to this: http://seo-website-designer.com/Zeus-Server-301-Redirect-Generator which created the rewrite.script file I needed.
In .htaccess found in your root document:
Redirect http://example.com/ http://www.example.com/
If there is no support for .htaccess on your server, you may have to include meta tag redirect on the head of your page. or using javascript to check the URL source then redirect it.

redirect directory to new address

hi i want redirect my directory to new address and remove .html ext from end
example:
http://www.mysite.com/viewdownload/11-e/652-elena-2010.html
redirect to
http://www.mysite.com/download/viewdownload/11-e/652-elena-2010
or
http://www.mysite.com/viewdownload/9-b/1281-birdsong-2012.html
redirect to
http://www.mysite.com/download/viewdownload/9-b/1281-birdsong-2012
Assuming mod_rewrite is installed, just use URL rewriting in your .htaccess files. You can use URL rewriting to redirect users as well as doing an internal transfer.
A good reference is here: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Note that if there is any custom logic to mapping your old URIs to your new ones you might want to rewrite the old URIs to a PHP script which then returns the needed file.

Simple modrewrite, how does a link appear?

When you use modrewrite to rewrite your urls, when does the rewrite occur. Will the user be able to see the url before rewrite, when hovering over the link? When they hover over a link will their browser display the rewritten url or the url before it was modified with modrewrite?
The rewrite is done in the server so the user will never know,
PHP also doesn't know what link its pointing to only the script file
mod_rewrite acts on the server side, meaning that apache rewrites incoming URLs before responding to the request. Any HTML links you add to a page will point to the URL you entered, as mod_rewrite doesn't modify any outgoing data.
The rewrite occurs when Apache has parsed the request - before the PHP interpreter has been started.