htaccess send content after ? as a parameter - php

This is my input URL
http://site_name/project/edit/sgdsg/getFile/?file=271bbec45d7855a332e6dfda85ca94b9.txt
I want it to be sent like
http://site_name/project/edit/sgdsg/getFile/271bbec45d7855a332e6dfda85ca94b9.txt
How can we do this? I want this only for the URL starting with http://site_name/project/edit/sgdsg/getFile/
So it don't affect any other URL.
This is what I have tried ...
RewriteRule ^project/edit/([A-Za-z0-9._-]+)/([A-Za-z0-9._-]+)/([A-Za-z0-9._-]+)/?$ modules-nct/edit_project-nct/index.php?slug=$1&action=method&method=$2&file=$3 [L]
RewriteRule ^project/edit/([A-Za-z0-9._-]+)/([A-Za-z0-9._-]+)/?$ modules-nct/edit_project-nct/index.php?slug=$1&action=method&method=$2 [L]
RewriteRule ^project/edit/([A-Za-z0-9._-]+)/?$ modules-nct/edit_project-nct/index.php?slug=$1 [L]
Please don't give it negative ratings just because my editing is improper.I am here to learn something new.
Thanks.

In your <a> tag:
<a href="your_url/your_other_parameters(means :project/edit/sgdsg/getFile/ )/directly enter your file name that you want to pass"> i.e your <a> tag must be
In htaccess:
RewriteRule ^project/edit/([A-Za-z0-9._-]+)/([A-Za-z0-9._-]+)/([A-Za-z0-9._-]+)$ modules-nct/edit_project-nct/index.php?slug=$1&action=method&method=$2&file=$3
In the above line, the href URL will be redirected to an original URL.

Related

title redirecting in htaccess for redirecting url or something like this

i want to redirect this please guide me
form
http://example.com/babycare/general_help/category.php?id=10
to
http://example.com/babycare/article/category/10
the id should change deynamicly i.e id may b 10,12,or 23 etc
Blockquote
Try use on .htaccess:
RewriteRule ^babycare/article/category/([0-9]+)$ babycare/general_help/category.php?id=$1
try this one, you need to change some part of it accoriding to your category
RewriteEngine On
RewriteRule ^category/(.+)/(.+)$ category.php?$1=$2 [NC,L]

htaccess: RewriteRule for URL rewriting

I have a link that looks like this
http://www.example.com/artistmusic?address=JKanyomozi
I would like to change this URL to
http://www.example.com/JKanyomozi/music
I've only been able to do this by adding music as a parameter instead of adding it to the new URL as a prefix.
In short, i've turned this URL ...
http://www.example.com/artistmusic?address=JKanyomozi&req=music
... using this rule ...
RewriteRule ^([^/]*)/([^/]*)$ /artistmusic?address=$1&req=$2 [L]
... into ...
http://www.example.com/JKanyomozi/music
But the problem with this is that for other pages like the one for the videos, this rule redirects to the same page http://www.example.com/JKanyomozi/music instead of http://www.example.com/JKanyomozi/videos
The videos page's original URL is something like this ...
http://www.example.com/artistvideos?address=JKanyomozi
Which rule can I use to change the URL above to
http://www.example.com/JKanyomozi/videos
This applies for other pages like artistevents, artistphotos and artistbiography
Thank you in advance!
Try this :
RewriteRule ^([^/]*)/([^/]*)$ /artist$2?address=$1 [L]

.htaccess URLs title in url not by id

I am trying tyo change my url address by title, doing change by id its work and show all the content but when trying by title its not show content
the .htaccess code is
RewriteRule ^blogview/([-a-zA-Z]+) single1.php?title=$1 [L,QSA]
and the page code is
<a class="bttn" href="/blogview/<?php echo $row['title']; ?>">MORE</a>
the link of url is Page link
Change the rule as following:
RewriteRule ^blogview/([A-Za-z\-]*)$ single1.php?title=$1 [L,QSA]

PHP - Remove the Specific Segment from URL

I have showing the ad banners in .../openx/banner.php
Each Banner I had set the Banner Link.
After clicking the Banners the Page is redirected with the following URL.
.../openx/www/delivery/ck.php?oaparams=2__bannerid=1__zoneid=1__cb=5b97a864fe__oadest=http%3A%2F%2Fwww.google.com
Here is the root URL : openx/
I want to remove the last segment that is oadest=http%3A%2F%2Fwww.google.com when the page is loaded.
Please anyone help me...
Thanks...
Assuming this string is always at the end of your url, try putting this in the appropriate place on your .htaccess file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)oadset=(.*)$
RewriteRule ^/?ck\.php$ /ck.php?%1 [L]

mod_rewrite rewriterule?

hello i have an anchor on my site. by calling my site the url will be:
http://site.com/page.php
by clicking a button the url will display an url that i would like to hide:
http://site.com/page.php#1
now i have found out that i can change this by using mod_rewrite tool. i tried this rule without success:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)\.html$
RewriteRule ^.*\.html$ %1.php [L]
for calling the page as html or php and to hide the #1 behind the .php
RewriteRule ^(.*)$ ./php#1=php$1
i really would appreciate if there is someone who could give me advise on how to solve this. thanks a lot.
You cannot achieve this via mod_rewrite.
URL after # are not passed through server.
If you still want to achieve this, you may want to look into doing it via JavaScript:
Check this out
JavaScript:
function scrollHere() {
// Scroll to the anchor
//(you may need to look for some script to achieve this)
return false; // to prevent URL overwriting
}
One such script is this jQuery.scrollTo.
The hashtag is never sent to the server, thus you simply cannot create a rule, that based on it.
You can do something like this to remove # tag.
Your text.
So when you write "javascript:void(0);" in href attribute of a tag and thats it.
HTML
<a href='page'>Home Page</a>
<a href='page/1'>Page 1</a>
<a href='page/2'>Page 2</a>
<a href='page/3'>Page 3</a>
Rewriting as
RewriteRule ^$ page.php [L]
RewriteRule ^([a-z]+)/?([0-9]*)/?$ page.php?index=$2 [L]
And check for index in php
<?php
if (isset($_GET['index']))
{
$pageNo =$_GET['index'];
}
//based on page NO display contents
?>

Categories