My problem is to redirect from subdirectory link to one file.
my current url
www.sample.com/stream/34/video.m3u8
www.sample.com/stream/35/video.m3u8
hope
www.sample.com/stream.php?param1=35¶m2=video.m3u8
or
www.sample.com/stream/index.php?param1=35¶m2=video.m3u8
Please save my life
You can do something like the following using mod_rewrite in the root .htaccess file in order to rewrite the request to /stream.php?param1=<id>¶m2=<file>:
Options -MultiViews
RewriteEngine On
RewriteRule ^stream/(\d+)/([\w-]+\.\w{2,4})$ stream.php?param1=$1¶m2=$2 [L]
This assumes that the <id> (2nd path segment) is entirely numeric and the 3rd path segment consists of <filename>.<ext>. You should restrict this to m3u8 if that is all you are expecting.
Related
I am trying to rewrite url using htaccess but it's saying 404.
RewriteEngine on
RewriteRule ^p/([a-z0-9])$ product1.php?pid=$1
It's not opening product1.php file.
You need to make sure your htaccess file and your product1.php file are in same folder. If not that it will give 404 errors.
If they are not present in same folder then you need to complete relative path from the path where your htaccess file is present like: eg: Let's say we have folder structure like:
/root/.htaccess
/root/singh/test/product1.php
So have your rules in following manner then:
RewriteEngine on
RewriteRule ^p/([a-z0-9])$ singh/test/product1.php?pid=$1 [NC,L]
Also apart from these put NC and L flags too in your rules to do case sensitive matching and making this condition's last rule here.
I am working on a new website and I want the following url /newsite/products to redirect to /newsite/products/product.php.
My .htaccess file is as follows:
RewriteEngine On
RewriteRule ^newsite/products$ /newsite/products/product.php
My problem is that there is already a folder called products within newsite and when requesting newsite/products it tries to open that folder rather than go to the php file.
I get:
Forbidden
You don't have permission to access /newsite/products/ on this server.
Is there any way to make this work?
EDIT: Requested url is: http://example.com/newsite/products and location of .htaccess is in root.
You need to turn off the directory slash to rewrite your file :
Try :
DirectorySlash off
RewriteEngine On
RewriteRule ^newsite/products$ /newsite/products/product.php [NC,L]
Don't add a trailing slash in rule pattern
/newsite/products
will rewrite to
/newsite/products/product.php
and
/newsite/products/
will open your "products" directory
Note- this is not a safe solution, if you remove the rule and DirectorySlash is off, Your index file will be ignored ,all directories will start listing files and folders.
I have this project called 'site01'.
It is published as: 'www.example.com/site01'. The pages are like this 'www.example.com/site01/page/1'.
I'm able to route the url to 'www.example.com/site01/1', but can I change the url to 'www.example.com/s/1' through the routes configuration?
Initially I think that you have to use .htaccess way, because the issue is related to the outside of the CakePHP folder.
You can create a new file named .htaccess in the upper folder and write the instruction witch redirect /site01/ to /s/.
sample code for rewrite url:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^site01.*$ /s/ [R=301,L]
I mirrored our Basecamp install to a Google Cloud Disk using wget. Many of the pages that were created are using the following file names:
Files
files.html?page=4
files.html?page=5
files.html?page=6
files.html?page=7
files.html?page=8
files.html?page=9
index
log?n=0
We were able to fix the index issue with log%3fn=0:
DirectoryIndex index.html index.htm log%3fn=0 log report new_more new
I wanted to see if there were a way to add a rewrite in .htaccess that will make
000.000.000.000/projects/11424851-m-domain-com/files.html?page=2
resolve to the file name that contains a query-string in it.
I am thinking the rewrite would have to produce:
000.000.000.000/projects/11424851-m-domain-com/files.html%3fnpage=2
Thank for any help!!
You can use something like:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^page=(.*)$
RewriteRule ^(.*)$ %{REQUEST_URI}\%3Fnpage=%1? [L]
I.e. match query strings starting with page=, and redirect to the same filename with the query string appended in escaped form.
I have tried but have not found proper solution for PHP .htaccess
Folder and files information:
.htaccess (on root)
/profile/personal.php
/profile/exam/exam_information.php
Sending URLs from (personal.php) and (exam_information.php)
/profile/2012/A1PPOAQU7
........\-------------/ // Friendly URL
/profile/exam/2012/A1PPOAQU7
.............\-------------/ // Friendly URL
I found, htaccess but it works for single URL only. Please check what is wrong in the code.
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+)$ /profile/personal.php?pid=$1
RewriteRule ^([a-zA-Z0-9-/]+)/$ /profile/personal.php?pid=$1