I Want to Generate Search Engine Friendly urls - url

I Want to Generate Search Engine Friendly urls for eg:- say I have a link below like
http://www.apexengineeringproject.com/display_project.php?id=AP112&title=ADVANCED%20OFFICE%20AUTOMATION%20SYSTEM%20USING%20GSM%20AND%20MICROCONTROLLER
I Just want it to be
http://www.apexengineeringproject.com/display_project.php/AP112/ADVANCED%20OFFICE%20AUTOMATION%20SYSTEM%20USING%20GSM%20AND%20MICROCONTROLLER
I tried with rewrite in .htaccess but didnt succeeded even Im not getting how to GET parameters once link is converted to seo friendly.So anybody please help me in this situation.
EDIT:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} \/index\.php [NC]
RewriteRule (.*) apexengineeringproject.com [R=301,L]
RewriteRule ^display_project.php/([^/]+)/([^/]+) /display_project.php?id=$1&title=$2 [NC]
This is the content of my .htaccess file but problem is page gets loaded but not the styles and javascripts.

Most likely, you're referencing your script/style files using a relative file name. The browser will use the whole directory path up to the last slash before the query string for fetching relative paths.
For example, when using the page before rewrite;
http://www.apexengineeringproject.com/display_project.php
...and it looks for a script at scripts/test.js, the browser will fetch it from;
http://www.apexengineeringproject.com/scripts/test.js
When using the page after rewrite;
http://www.apexengineeringproject.com/display_project.php/AP112/ADVANCED%20OFFICE%20AUTOMATION%20SYSTEM%20USING%20GSM%20AND%20MICROCONTROLLER
...a fetch of the relative path scripts/test.js will fetch the file;
http://www.apexengineeringproject.com/display_project.php/AP112/scripts/test.js
...which presumably does not exist.
To fix the problem, just make your script paths and css paths relative to the server root, ie don't use scripts/test.js, instead use /scripts/test.js.
EDIT: Although I'd consider it slightly hacky, you could rewrite some files back to the root. Can't test this, but it should be close to what you want;
RewriteCond %{REQUEST_URI} \.(jpg|css|png|js)$ [NC]
RewriteRule display_project.php/[^/]*(.*) $1 [NC]

Related

wildcard_charcters.sitename routing issues

i would like to incorporate wildcard characters to my site. so previously it was
www.mysite.com/user/mike or www.mysite.com/user/dave will look like
mike.mysite.com or dave.mysite.com. i tried .htacces rewriting but those were of rewriting for sub-domains and it was creating problems with css and images.I just want that too call user function with value we pass.I use RoR MVC framework.(i'm sure .htacces solve this issue but i don't know if we can give wildcards in routes too).
and i would like to keep other links normal like www.mysite/project/dashboard or www.mysite/project/messages.
Thanks in advance.
edit
i tried this but it dosent work, it's goes to site5s default page.
Options +FollowSymLinks
RewriteEngine On
RewriteCond ^(.*)$.example.com [NC]
RewriteRule ^(.*)$ http://example.com/user/$1 [R=301,L]'
ok, finnaly i was able to do it,there will be few things which you have to do first.
paste this code in .htaccess first of all.
Options +FollowSymLinks
RewriteEngine On
// enable rewriting
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ // Check for wildcard character before example.com
RewriteCond %1 !=www // check if www is not present in URL
RewriteRule ^(.*)$ http://www.example.com/user/%1/$1 [R=302,L] // Redirect URL and replace matched wildcard character "^(.+)" in place of "$1"
Now we have defined the rules for that, now it's turn of redirection. above code won't be able to work.
for that you have to create a wildcard sub domain in from your Cpanle. Create a sub domain *.example.com and point to your public_html(you subsite if t\redirected site is a child site)

prevent users from seeing full path

I want to know if there is a way to prevent visitors on the website to see the full site url .. so for example instead of http://www.5eren.dk/index.php all the user see's is http://www.5eren.dk .. is this possible ?
If i am understanding you correctly check out .htaccess rewrite condition and rewrite engine.
For example to hide a file extension:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
This should get you started.
Simply NO
However, depending on your server-side scripting technology you use on your website, such functionality may be applied by a mean of central script that call some URL on your website and render it as it is being the requested script with some param.
For example:
Suppose the following URL
http://myexample.com/secrets/pages/output.php
Now we may request it using some routing script as follows:
http://myexample.com/routing.php?routeID=123
Using some database inside your routing script you may able to call or include the secrets/pages/ouput.php

Magento custom URL Rewrite not working

On my website there is a collection of pdf files for manuals, brochures, MSDS etc. The links to download these files are scattered across a "downloads" area, informational pages and product page. We update the brochures on a regular basis so in order to not have to update every single page where the file is linked from I need to know how to create a redirect where the old URL:
http://easypropondproducts.com/media/pdfs/EcoPondKitsBroch-MPF-109.pdf
will permanently redirect to the new URL
http://easypropondproducts.com/media/pdfs/EcoPondKitsBroch-MPF-512.pdf
I have tried custom URL rewrites and it doesn't seem to work how I have configured it:
Type: custom
ID Path: /media/pdfs/EcoPondKitsBroch-MPF-109.pdf
Request Path: /media/pdfs/EcoPondKitsBroch-MPF-109.pdf
Target Path: http://easypropondproducts.com/media/pdfs/EcoPondKitsBroch-MPF-512.pdf
Redirect: Permanent (301)
What am I doing wrong? Is there any way to do this?
You cannot rewrite files in the media folder by using Magentos internal URL Rewrite Management.
That's because URLs pointing to Magentos media (or skin or js) folder don't even reach the central entry point at index.php, but are served directly.
Take a look at Magentos root .htaccess file:
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
With your URL, the first RewriteCond is the one that doesn't match. This condition says "if the URL does NOT start with /media/ or /skin/ or /js/".
But your URL does start with /media/. Hence it will not be rewritten to index.php and cannot reach Magentos internal URL Rewrite Management.
To achieve what you want you could insert the following line right before the first RewriteCond:
Redirect 301 /media/pdfs/EcoPondKitsBroch-MPF-109.pdf /media/pdfs/EcoPondKitsBroch-MPF-512.pdf

Codeigniter setup

I'm wondering if there is something wrong with my CI setup. If I load the base_url ie http://localhost/~User/project/
then it loads perfectly, adding the index.php before the default controller. However,
my config file has
$config['index_page'] = '';
As a test I returned this value to 'index.php'. When I loaded the base_url after this it returned: http://localhost/~User/project/index.php/index.php/controller/method
Is this what I shoul expect? I'm having big problems with my .htaccess file which doesn't seem to be working. I posted this as a separate question incase the two are unrelated.
UPDATE: I've now got the .htaccess working and the index.php has disappeared BUT ONLY IF TYPE THE FULL URL.
If I just type the base_url then it loads the default controller but still adds the index.php into the string.
To clarify...
If I type:
http://localhost/~User/project/controller/method
everything works as expected and the URL stays exactly like this. Similarly if I follow relative links then the correct controllers and methods are loaded with index.php appearing in the URL.
If, however, I only type:
http://localhost/~User/project
it redirects me to
http://localhost/~User/project/index.php/controller/method
The controller is the default that I have setup in my config file and I have also set
$this->config['index_page'] = '';
Have you followed this tutorial to the letter?
Try using the following .htaccess file, it has never let me down so far:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
</IfModule>
SOLVED:
Ok this makes me feel really stupid, but I found the cause of the problem. I had a redirect function tucked away in MY_Controller that I'd completely forgotten about. Because previously i couldn't get the .htaccess to work, I'd hard-coded the redirect to include index.php.
Everything is now working as it should. Many apologies for wasting your time trying to solve a problem that didn't exist!

how do I redirect from a subdirectory to another directory, but strip off the original subdirectory from the URI using mod_rewrite

I have a Ruby on Rails app running on 12001. I am currently redirecting a subdomain to 127.0.0.1:12001 using some ReWriteCond detection.
Now I want to redirect my subdirectory to that rails app.
http[s]://domain.com/redmine
to
127.0.0.1:12001
The current rules apply REQUEST_URI to the above rails path, but I need to strip "/redmine" from the front of REQUEST_URI...
Any ideas?
You can do this without mod_rewrite.
Redirect Permanent /redmine http://127.0.0.1:12001
This should do what you want.
RewriteRule ^/redmine/(.*)$ http://127.0.0.1:12001/$1 [QSA,L]
If the rule is placed in the Directory directive, then:
RewriteRule ^redmine/(.*)$ http://127.0.0.1:12001/$1 [QSA,L]
The parameters at the end:
[QSA] appends the query string (up to you);
[L] makes it the last rule
NB /redmine will not be matched by this rule, but I am going off what you tried, only subpaths, e.g. /redmine/abc

Resources